Skip to content

Commit

Permalink
Fixed TestDepthBuffer in Testbed for GL.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Jul 29, 2023
1 parent b6e99d6 commit 1b0e852
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* GLCoreExtensions.cpp
*
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/
Expand Down
22 changes: 11 additions & 11 deletions sources/Renderer/OpenGL/Shader/GLShaderBindingLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void GLShaderBindingLayout::UniformAndBlockBinding(GLuint program, GLStateManage
for_range(i, numUniformBindings_)
{
const auto& resource = bindings_[resourceIndex++];
auto blockIndex = glGetUniformLocation(program, resource.name.c_str());
if (blockIndex != GL_INVALID_INDEX)
glProgramUniform1i(program, blockIndex, static_cast<GLint>(resource.slot));
GLint location = glGetUniformLocation(program, resource.name.c_str());
if (location != GL_INVALID_INDEX)
glProgramUniform1i(program, location, static_cast<GLint>(resource.slot));
}
}
else
Expand All @@ -50,9 +50,9 @@ void GLShaderBindingLayout::UniformAndBlockBinding(GLuint program, GLStateManage
for_range(i, numUniformBindings_)
{
const auto& resource = bindings_[resourceIndex++];
auto blockIndex = glGetUniformLocation(program, resource.name.c_str());
if (blockIndex != GL_INVALID_INDEX)
glUniform1i(blockIndex, static_cast<GLint>(resource.slot));
GLint location = glGetUniformLocation(program, resource.name.c_str());
if (location != GL_INVALID_INDEX)
glUniform1i(location, static_cast<GLint>(resource.slot));
}
}
stateMngr->PopBoundShaderProgram();
Expand All @@ -62,17 +62,17 @@ void GLShaderBindingLayout::UniformAndBlockBinding(GLuint program, GLStateManage
for_range(i, numUniformBindings_)
{
const auto& resource = bindings_[resourceIndex++];
auto blockIndex = glGetUniformLocation(program, resource.name.c_str());
if (blockIndex != GL_INVALID_INDEX)
glUniform1i(blockIndex, static_cast<GLint>(resource.slot));
GLint location = glGetUniformLocation(program, resource.name.c_str());
if (location != GL_INVALID_INDEX)
glUniform1i(location, static_cast<GLint>(resource.slot));
}
}

/* Set uniform-block bindings */
for_range(i, numUniformBlockBindings_)
{
const auto& resource = bindings_[resourceIndex++];
auto blockIndex = glGetUniformBlockIndex(program, resource.name.c_str());
GLuint blockIndex = glGetUniformBlockIndex(program, resource.name.c_str());
if (blockIndex != GL_INVALID_INDEX)
glUniformBlockBinding(program, blockIndex, resource.slot);
}
Expand All @@ -82,7 +82,7 @@ void GLShaderBindingLayout::UniformAndBlockBinding(GLuint program, GLStateManage
for_range(i, numShaderStorageBindings_)
{
const auto& resource = bindings_[resourceIndex++];
auto blockIndex = glGetProgramResourceIndex(program, GL_SHADER_STORAGE_BLOCK, resource.name.c_str());
GLuint blockIndex = glGetProgramResourceIndex(program, GL_SHADER_STORAGE_BLOCK, resource.name.c_str());
if (blockIndex != GL_INVALID_INDEX)
glShaderStorageBlockBinding(program, blockIndex, resource.slot);
}
Expand Down
1 change: 0 additions & 1 deletion tests/Testbed/Shaders/TriangleMesh.330core.vert
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ void main()
#if ENABLE_TEXTURING
vTexCoord = texCoord;
#endif
gl_Position.y = -gl_Position.y; //TODO: temporary fix for render target VS
}

9 changes: 9 additions & 0 deletions tests/Testbed/TestDepthBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ DEF_TEST( DepthBuffer )
}
PipelineState* pso = renderer->CreatePipelineState(psoDesc);

if (const Report* report = pso->GetReport())
{
if (report->HasErrors())
{
Log::Errorf("PSO creation failed:\n%s", report->GetText());
return TestResult::FailedErrors;
}
}

// Update scene constants
sceneConstants.wMatrix.LoadIdentity();
Gs::Translate(sceneConstants.wMatrix, Gs::Vector3f{ 0, 0, 2 });
Expand Down
10 changes: 2 additions & 8 deletions tests/Testbed/TestbedContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ bool TestbedContext::LoadShaders()
shaderDesc.entryPoint = entry;
shaderDesc.profile = profile;
shaderDesc.defines = defines;
shaderDesc.flags = ShaderCompileFlags::PatchClippingOrigin;
shaderDesc.vertex.inputAttribs = vertexFormat.attributes;
}
Shader* shader = renderer->CreateShader(shaderDesc);
Expand Down Expand Up @@ -568,14 +569,7 @@ bool TestbedContext::LoadShaders()
shaders[VSTextured] = LoadShaderFromFile(shaderPath + "TriangleMesh.hlsl", ShaderType::Vertex, "VSMain", "vs_5_0", definesEnableTexturing);
shaders[PSTextured] = LoadShaderFromFile(shaderPath + "TriangleMesh.hlsl", ShaderType::Fragment, "PSMain", "ps_5_0", definesEnableTexturing);
}
else if (IsShadingLanguageSupported(ShadingLanguage::GLSL_450))
{
shaders[VSSolid] = LoadShaderFromFile(shaderPath + "TriangleMesh.450core.vert", ShaderType::Vertex);
shaders[PSSolid] = LoadShaderFromFile(shaderPath + "TriangleMesh.450core.frag", ShaderType::Fragment);
shaders[VSTextured] = LoadShaderFromFile(shaderPath + "TriangleMesh.450core.vert", ShaderType::Vertex, nullptr, nullptr, definesEnableTexturing);
shaders[PSTextured] = LoadShaderFromFile(shaderPath + "TriangleMesh.450core.frag", ShaderType::Fragment, nullptr, nullptr, definesEnableTexturing);
}
else if (IsShadingLanguageSupported(ShadingLanguage::GLSL_330))
else if (IsShadingLanguageSupported(ShadingLanguage::GLSL))
{
shaders[VSSolid] = LoadShaderFromFile(shaderPath + "TriangleMesh.330core.vert", ShaderType::Vertex);
shaders[PSSolid] = LoadShaderFromFile(shaderPath + "TriangleMesh.330core.frag", ShaderType::Fragment);
Expand Down

0 comments on commit 1b0e852

Please sign in to comment.