GameFoundry / bsf

Modern C++14 library for the development of real-time graphical applications

Home Page:https://www.bsframework.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openGL renderAPI scissor not immediate

pgruenbacher opened this issue · comments

compare the GL render api

void GLRenderAPI::setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom,
const SPtr<CommandBuffer>& commandBuffer)
{
auto executeRef = [&](UINT32 left, UINT32 top, UINT32 right, UINT32 bottom)
{
THROW_IF_NOT_CORE_THREAD;
mScissorTop = top;
mScissorBottom = bottom;
mScissorLeft = left;
mScissorRight = right;
};

to the D3D11 render api implementation.

void D3D11RenderAPI::setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom,
const SPtr<CommandBuffer>& commandBuffer)
{
auto executeRef = [&](UINT32 left, UINT32 top, UINT32 right, UINT32 bottom)
{
THROW_IF_NOT_CORE_THREAD;
mScissorRect.left = static_cast<LONG>(left);
mScissorRect.top = static_cast<LONG>(top);
mScissorRect.bottom = static_cast<LONG>(bottom);
mScissorRect.right = static_cast<LONG>(right);
mDevice->getImmediateContext()->RSSetScissorRects(1, &mScissorRect);
};

I noticed this when doing the imgui implementation. https://github.com/pgruenbacher/bsf/blob/020e89a68feb84defeaaa59386d6036bafa4e74c/Source/Plugins/bsfImgui/Src/BsImguiRenderer.cpp#L238
it appears that the glScissor is only called when enableScissor is called. One way was to re-update the graphicsPipeline. Other way was I just updated the render api to do glScissorRect. However now there's the issue that the glScissorRect is being called redundantly.
https://github.com/pgruenbacher/bsf/blob/020e89a68feb84defeaaa59386d6036bafa4e74c/Source/Plugins/bsfGLRenderAPI/BsGLRenderAPI.cpp#L1281

my guess is that the setScissorTestEnable in the gl render api needs to be updated as well, maybe get rid of the following lines and move them to the setScissorRect?

BS_CHECK_GL_ERROR();
x = mScissorLeft;
y = rtProps.height - mScissorBottom;
w = mScissorRight - mScissorLeft;
h = mScissorBottom - mScissorTop;
glScissor(x, y, w, h);
BS_CHECK_GL_ERROR();

This should be resolved on latest.

confirmed to work.