OpenGLRenderer: Minor fixes

This commit is contained in:
Jérôme Leclercq
2021-05-26 22:20:10 +02:00
parent e7a2573221
commit 7fe60026be
9 changed files with 26 additions and 138 deletions

View File

@@ -71,7 +71,7 @@ namespace Nz
if constexpr (std::is_same_v<T, BeginDebugRegionData>)
{
if (context->glPushDebugGroup)
context->glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, command.regionName.size(), command.regionName.data());
context->glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(command.regionName.size()), command.regionName.data());
}
else if constexpr (std::is_same_v<T, CopyBufferData>)
{
@@ -143,11 +143,12 @@ namespace Nz
void OpenGLCommandBuffer::ApplyStates(const GL::Context& context, const DrawStates& states)
{
states.shaderBindings->Apply(context);
states.pipeline->Apply(context);
states.pipeline->FlipY(states.shouldFlipY);
states.shaderBindings->Apply(context);
if (states.scissorRegion)
context.SetScissorBox(states.scissorRegion->x, states.scissorRegion->y, states.scissorRegion->width, states.scissorRegion->height);

View File

@@ -51,10 +51,10 @@ namespace Nz
const auto& bindingDesc = layoutInfo.bindings[binding.bindingIndex];
std::size_t resourceIndex = 0;
for (std::size_t i = binding.bindingIndex; i > 0; --i)
for (std::size_t j = binding.bindingIndex; j > 0; --j)
{
// Use i-1 to prevent underflow in for loop
if (layoutInfo.bindings[i - 1].type == bindingDesc.type)
// Use j-1 to prevent underflow in for loop
if (layoutInfo.bindings[j - 1].type == bindingDesc.type)
resourceIndex++;
}
@@ -99,7 +99,7 @@ namespace Nz
const UniformBufferBinding& uboBinding = std::get<UniformBufferBinding>(binding.content);
auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, resourceIndex);
uboDescriptor.bindingIndex = binding.bindingIndex;
uboDescriptor.bindingIndex = static_cast<UInt32>(binding.bindingIndex);
uboDescriptor.offset = uboBinding.offset;
uboDescriptor.size = uboBinding.range;

View File

@@ -125,7 +125,7 @@ namespace Nz
std::string code = writer.Generate(shaderStage, shaderAst, states);
shader.SetSource(code.data(), code.size());
shader.SetSource(code.data(), GLint(code.size()));
shader.Compile();
CheckCompilationStatus(shader);

View File

@@ -214,6 +214,9 @@ namespace Nz::GL
unit.buffer = buffer;
unit.offset = offset;
unit.size = size;
// glBindBufferRange does replace the currently bound buffer
m_state.bufferTargets[UnderlyingCast(BufferTarget::Uniform)] = buffer;
}
}