From 1b0e85279737310d7025cd3d5d89902f561d1f9f Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Fri, 28 Jul 2023 20:10:13 -0400 Subject: [PATCH] Fixed TestDepthBuffer in Testbed for GL. --- .../OpenGL/GLCoreProfile/GLCoreExtensions.cpp | 2 +- .../OpenGL/Shader/GLShaderBindingLayout.cpp | 22 +++++++++---------- .../Testbed/Shaders/TriangleMesh.330core.vert | 1 - tests/Testbed/TestDepthBuffer.cpp | 9 ++++++++ tests/Testbed/TestbedContext.cpp | 10 ++------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensions.cpp b/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensions.cpp index a74cdaa6bd..ffcd6a42d4 100644 --- a/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensions.cpp +++ b/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensions.cpp @@ -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). */ diff --git a/sources/Renderer/OpenGL/Shader/GLShaderBindingLayout.cpp b/sources/Renderer/OpenGL/Shader/GLShaderBindingLayout.cpp index e90b503771..afd627b232 100644 --- a/sources/Renderer/OpenGL/Shader/GLShaderBindingLayout.cpp +++ b/sources/Renderer/OpenGL/Shader/GLShaderBindingLayout.cpp @@ -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(resource.slot)); + GLint location = glGetUniformLocation(program, resource.name.c_str()); + if (location != GL_INVALID_INDEX) + glProgramUniform1i(program, location, static_cast(resource.slot)); } } else @@ -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(resource.slot)); + GLint location = glGetUniformLocation(program, resource.name.c_str()); + if (location != GL_INVALID_INDEX) + glUniform1i(location, static_cast(resource.slot)); } } stateMngr->PopBoundShaderProgram(); @@ -62,9 +62,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(resource.slot)); + GLint location = glGetUniformLocation(program, resource.name.c_str()); + if (location != GL_INVALID_INDEX) + glUniform1i(location, static_cast(resource.slot)); } } @@ -72,7 +72,7 @@ void GLShaderBindingLayout::UniformAndBlockBinding(GLuint program, GLStateManage 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); } @@ -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); } diff --git a/tests/Testbed/Shaders/TriangleMesh.330core.vert b/tests/Testbed/Shaders/TriangleMesh.330core.vert index 2b7d4ce290..1f56cbd266 100644 --- a/tests/Testbed/Shaders/TriangleMesh.330core.vert +++ b/tests/Testbed/Shaders/TriangleMesh.330core.vert @@ -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 } diff --git a/tests/Testbed/TestDepthBuffer.cpp b/tests/Testbed/TestDepthBuffer.cpp index 1c0db6ffaa..afede1dd58 100644 --- a/tests/Testbed/TestDepthBuffer.cpp +++ b/tests/Testbed/TestDepthBuffer.cpp @@ -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 }); diff --git a/tests/Testbed/TestbedContext.cpp b/tests/Testbed/TestbedContext.cpp index e3a61f44cc..69938e2403 100644 --- a/tests/Testbed/TestbedContext.cpp +++ b/tests/Testbed/TestbedContext.cpp @@ -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); @@ -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);