Moves glViewport from CRenderer to CDeviceCommandContext.

This was SVN commit r26497.
This commit is contained in:
vladislavbelov
2022-02-26 23:17:48 +00:00
parent a217718254
commit da4ec670c1
8 changed files with 27 additions and 15 deletions
+1 -1
View File
@@ -523,7 +523,7 @@ void CMiniMapTexture::RenderFinalTexture(
if (m_EntitiesDrawn > 0)
{
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = scissorRect.y = 1;
scissorRect.width = scissorRect.height = FINAL_TEXTURE_SIZE - 2;
deviceCommandContext->SetScissors(1, &scissorRect);
+1 -1
View File
@@ -444,7 +444,7 @@ void CGUIText::Draw(CGUI& pGUI, CCanvas2D& canvas, const CGUIColor& DefaultColor
clipping.right = std::floor(clipping.right);
const float scale = g_VideoMode.GetScale();
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = std::ceil(clipping.left * scale);
scissorRect.y = std::ceil(g_yres - clipping.bottom * scale);
scissorRect.width = std::floor(clipping.GetWidth() * scale);
+1 -1
View File
@@ -1244,7 +1244,7 @@ void CInput::Draw(CCanvas2D& canvas)
if (cliparea != CRect())
{
const float scale = g_VideoMode.GetScale();
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = cliparea.left * scale;
scissorRect.y = g_yres - cliparea.bottom * scale;
scissorRect.width = cliparea.GetWidth() * scale;
+6 -1
View File
@@ -735,7 +735,12 @@ void CRenderer::EndFrame()
void CRenderer::SetViewport(const SViewPort &vp)
{
m_Viewport = vp;
glViewport((GLint)vp.m_X,(GLint)vp.m_Y,(GLsizei)vp.m_Width,(GLsizei)vp.m_Height);
Renderer::Backend::GL::CDeviceCommandContext::Rect viewportRect;
viewportRect.x = vp.m_X;
viewportRect.y = vp.m_Y;
viewportRect.width = vp.m_Width;
viewportRect.height = vp.m_Height;
m->deviceCommandContext->SetViewports(1, &viewportRect);
}
SViewPort CRenderer::GetViewport()
+2 -2
View File
@@ -570,7 +570,7 @@ void CSceneRenderer::RenderReflections(
screenScissor.x2 = (GLint)ceil((reflectionScissor[1].X*0.5f+0.5f)*vpWidth);
screenScissor.y2 = (GLint)ceil((reflectionScissor[1].Y*0.5f+0.5f)*vpHeight);
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = screenScissor.x1;
scissorRect.y = screenScissor.y1;
scissorRect.width = screenScissor.x2 - screenScissor.x1;
@@ -652,7 +652,7 @@ void CSceneRenderer::RenderRefractions(
screenScissor.x2 = (GLint)ceil((refractionScissor[1].X*0.5f+0.5f)*vpWidth);
screenScissor.y2 = (GLint)ceil((refractionScissor[1].Y*0.5f+0.5f)*vpHeight);
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = screenScissor.x1;
scissorRect.y = screenScissor.y1;
scissorRect.width = screenScissor.x2 - screenScissor.x1;
+1 -1
View File
@@ -603,7 +603,7 @@ void ShadowMap::PrepareCamera(const int cascade)
g_Renderer.GetSceneRenderer().SetViewCamera(camera);
const SViewPort& cascadeViewPort = m->Cascades[cascade].ViewPort;
Renderer::Backend::GL::CDeviceCommandContext::ScissorRect scissorRect;
Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
scissorRect.x = cascadeViewPort.m_X;
scissorRect.y = cascadeViewPort.m_Y;
scissorRect.width = cascadeViewPort.m_Width;
@@ -56,8 +56,8 @@ bool operator!=(const StencilOpState& lhs, const StencilOpState& rhs)
}
bool operator==(
const CDeviceCommandContext::ScissorRect& lhs,
const CDeviceCommandContext::ScissorRect& rhs)
const CDeviceCommandContext::Rect& lhs,
const CDeviceCommandContext::Rect& rhs)
{
return
lhs.x == rhs.x && lhs.y == rhs.y &&
@@ -65,8 +65,8 @@ bool operator==(
}
bool operator!=(
const CDeviceCommandContext::ScissorRect& lhs,
const CDeviceCommandContext::ScissorRect& rhs)
const CDeviceCommandContext::Rect& lhs,
const CDeviceCommandContext::Rect& rhs)
{
return !operator==(lhs, rhs);
}
@@ -683,7 +683,7 @@ void CDeviceCommandContext::SetFramebuffer(CFramebuffer* framebuffer)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->GetHandle());
}
void CDeviceCommandContext::SetScissors(const uint32_t scissorCount, const ScissorRect* scissors)
void CDeviceCommandContext::SetScissors(const uint32_t scissorCount, const Rect* scissors)
{
ENSURE(scissorCount <= 1);
if (scissorCount == 0)
@@ -705,6 +705,12 @@ void CDeviceCommandContext::SetScissors(const uint32_t scissorCount, const Sciss
m_ScissorCount = scissorCount;
}
void CDeviceCommandContext::SetViewports(const uint32_t viewportCount, const Rect* viewports)
{
ENSURE(viewportCount == 1);
glViewport(viewports[0].x, viewports[0].y, viewports[0].width, viewports[0].height);
}
CDeviceCommandContext::ScopedBind::ScopedBind(
CDeviceCommandContext* deviceCommandContext,
const GLenum target, const GLuint handle)
@@ -77,12 +77,13 @@ public:
const UploadBufferFunction& uploadFunction);
// TODO: maybe we should add a more common type, like CRectI.
struct ScissorRect
struct Rect
{
int32_t x, y;
int32_t width, height;
};
void SetScissors(const uint32_t scissorCount, const ScissorRect* scissors);
void SetScissors(const uint32_t scissorCount, const Rect* scissors);
void SetViewports(const uint32_t viewportCount, const Rect* viewports);
void BeginScopedLabel(const char* name);
void EndScopedLabel();
@@ -111,7 +112,7 @@ private:
CFramebuffer* m_Framebuffer = nullptr;
uint32_t m_ScissorCount = 0;
// GL2.1 doesn't support more than 1 scissor.
std::array<ScissorRect, 1> m_Scissors;
std::array<Rect, 1> m_Scissors;
uint32_t m_ScopedLabelDepth = 0;