diff --git a/sources/Renderer/OpenGL/Command/GLCommand.h b/sources/Renderer/OpenGL/Command/GLCommand.h index 6f80be5a47..021ac8a869 100644 --- a/sources/Renderer/OpenGL/Command/GLCommand.h +++ b/sources/Renderer/OpenGL/Command/GLCommand.h @@ -253,7 +253,7 @@ struct GLCmdSetStencilRef GLenum face; }; -struct GLCmdSetUniforms +struct GLCmdSetUniform { GLuint program; UniformType type; diff --git a/sources/Renderer/OpenGL/Command/GLCommandAssembler.cpp b/sources/Renderer/OpenGL/Command/GLCommandAssembler.cpp index c5e77dcfe2..2b6c04b420 100644 --- a/sources/Renderer/OpenGL/Command/GLCommandAssembler.cpp +++ b/sources/Renderer/OpenGL/Command/GLCommandAssembler.cpp @@ -285,10 +285,10 @@ static std::size_t AssembleGLCommand(const GLOpcode opcode, const void* pc, JITC compiler.CallMember(&GLStateManager::SetStencilRef, g_stateMngrArg, cmd->ref, cmd->face); return sizeof(*cmd); } - case GLOpcodeSetUniforms: + case GLOpcodeSetUniform: { - auto cmd = reinterpret_cast(pc); - compiler.Call(GLSetUniformsByType, cmd->type, cmd->location, cmd->count, (cmd + 1)); + auto cmd = reinterpret_cast(pc); + compiler.Call(GLSetUniform, cmd->type, cmd->location, cmd->count, (cmd + 1)); return (sizeof(*cmd) + cmd->size); } case GLOpcodeBeginQuery: diff --git a/sources/Renderer/OpenGL/Command/GLCommandExecutor.cpp b/sources/Renderer/OpenGL/Command/GLCommandExecutor.cpp index 455ef28aa8..65395d7652 100644 --- a/sources/Renderer/OpenGL/Command/GLCommandExecutor.cpp +++ b/sources/Renderer/OpenGL/Command/GLCommandExecutor.cpp @@ -282,10 +282,10 @@ static std::size_t ExecuteGLCommand(const GLOpcode opcode, const void* pc, GLSta stateMngr->SetStencilRef(cmd->ref, cmd->face); return sizeof(*cmd); } - case GLOpcodeSetUniforms: + case GLOpcodeSetUniform: { - auto cmd = reinterpret_cast(pc); - GLSetUniformsByType(cmd->type, cmd->location, cmd->count, (cmd + 1)); + auto cmd = reinterpret_cast(pc); + GLSetUniform(cmd->type, cmd->location, cmd->count, (cmd + 1)); return (sizeof(*cmd) + cmd->size); } case GLOpcodeBeginQuery: diff --git a/sources/Renderer/OpenGL/Command/GLCommandOpcode.h b/sources/Renderer/OpenGL/Command/GLCommandOpcode.h index bed03d25af..c695f5c4ef 100644 --- a/sources/Renderer/OpenGL/Command/GLCommandOpcode.h +++ b/sources/Renderer/OpenGL/Command/GLCommandOpcode.h @@ -53,7 +53,7 @@ enum GLOpcode : std::uint8_t GLOpcodeBindPipelineState, GLOpcodeSetBlendColor, GLOpcodeSetStencilRef, - GLOpcodeSetUniforms, + GLOpcodeSetUniform, GLOpcodeBeginQuery, GLOpcodeEndQuery, GLOpcodeBeginConditionalRender, diff --git a/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.cpp b/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.cpp index 72f5963320..e6572c6326 100644 --- a/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.cpp +++ b/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.cpp @@ -622,7 +622,7 @@ void GLDeferredCommandBuffer::SetUniforms(std::uint32_t first, const void* data, /* Allocate GL command and copy data buffer */ const auto& uniform = uniformMap[first]; const std::uint32_t uniformSize = uniform.wordSize * 4; - auto cmd = AllocCommand(GLOpcodeSetUniforms, dataSize); + auto cmd = AllocCommand(GLOpcodeSetUniform, dataSize); { cmd->program = boundShaderPipeline->GetID(); //TODO: must distinguish between GLShaderProgram and GLProgramPipeline cmd->type = uniform.type; diff --git a/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.cpp b/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.cpp index 75e070ba6b..65bf994f83 100644 --- a/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.cpp +++ b/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.cpp @@ -522,7 +522,7 @@ void GLImmediateCommandBuffer::SetUniforms(std::uint32_t first, const void* data return /*GL_INVALID_INDEX*/; const auto& uniform = uniformMap[first]; - GLSetUniformsByType(uniform.type, uniform.location, uniform.count, words); + GLSetUniform(uniform.type, uniform.location, uniform.count, words); words += uniform.wordSize; } diff --git a/sources/Renderer/OpenGL/GLStaticAssertions.cpp b/sources/Renderer/OpenGL/GLStaticAssertions.cpp index 4872d175a0..b6e7a97598 100644 --- a/sources/Renderer/OpenGL/GLStaticAssertions.cpp +++ b/sources/Renderer/OpenGL/GLStaticAssertions.cpp @@ -63,7 +63,7 @@ LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdBindRenderTarget ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdBindPipelineState ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdSetBlendColor ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdSetStencilRef ); -LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdSetUniforms ); +LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdSetUniform ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdBeginQuery ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdEndQuery ); LLGL_ASSERT_STDLAYOUT_STRUCT( GLCmdBeginConditionalRender ); diff --git a/sources/Renderer/OpenGL/Shader/GLShaderUniform.cpp b/sources/Renderer/OpenGL/Shader/GLShaderUniform.cpp index 3ea938c9f8..214fc8da1d 100644 --- a/sources/Renderer/OpenGL/Shader/GLShaderUniform.cpp +++ b/sources/Renderer/OpenGL/Shader/GLShaderUniform.cpp @@ -16,7 +16,7 @@ namespace LLGL // Requires GL 2.0 -static void GLSetUniformsInt(UniformType type, GLint location, GLsizei count, const GLint* data) +static void GLSetUniformInt(UniformType type, GLint location, GLsizei count, const GLint* data) { switch (type) { @@ -45,7 +45,7 @@ static void GLSetUniformsInt(UniformType type, GLint location, GLsizei count, co } // Requires GL 2.0 -static void GLSetUniformsFloat(UniformType type, GLint location, GLsizei count, const GLfloat* data) +static void GLSetUniformFloat(UniformType type, GLint location, GLsizei count, const GLfloat* data) { switch (type) { @@ -76,7 +76,7 @@ static void GLSetUniformsFloat(UniformType type, GLint location, GLsizei count, } // Requires GL 2.1 -static void GLSetUniformsFloatNxM(UniformType type, GLint location, GLsizei count, const GLfloat* data) +static void GLSetUniformFloatNxM(UniformType type, GLint location, GLsizei count, const GLfloat* data) { if (!HasExtension(GLExt::ARB_shader_objects_21)) return; @@ -107,7 +107,7 @@ static void GLSetUniformsFloatNxM(UniformType type, GLint location, GLsizei coun } // Requires GL 3.0 -static void GLSetUniformsUInt(UniformType type, GLint location, GLsizei count, const GLuint* data) +static void GLSetUniformUInt(UniformType type, GLint location, GLsizei count, const GLuint* data) { if (!HasExtension(GLExt::ARB_shader_objects_30)) return; @@ -134,7 +134,7 @@ static void GLSetUniformsUInt(UniformType type, GLint location, GLsizei count, c #ifdef LLGL_OPENGL // Requires GL 4.0 -static void GLSetUniformsDouble(UniformType type, GLint location, GLsizei count, const GLdouble* data) +static void GLSetUniformDouble(UniformType type, GLint location, GLsizei count, const GLdouble* data) { if (!HasExtension(GLExt::ARB_shader_objects_40)) return; @@ -188,7 +188,7 @@ static void GLSetUniformsDouble(UniformType type, GLint location, GLsizei count, #endif // /LLGL_OPENGL -void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const void* data) +void GLSetUniform(UniformType type, GLint location, GLsizei count, const void* data) { switch (type) { @@ -200,7 +200,7 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Float2: case UniformType::Float3: case UniformType::Float4: - GLSetUniformsFloat(type, location, count, reinterpret_cast(data)); + GLSetUniformFloat(type, location, count, reinterpret_cast(data)); break; case UniformType::Double1: @@ -208,7 +208,7 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Double3: case UniformType::Double4: #ifdef LLGL_OPENGL - GLSetUniformsDouble(type, location, count, reinterpret_cast(data)); + GLSetUniformDouble(type, location, count, reinterpret_cast(data)); #endif break; @@ -216,28 +216,28 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Int2: case UniformType::Int3: case UniformType::Int4: - GLSetUniformsInt(type, location, count, reinterpret_cast(data)); + GLSetUniformInt(type, location, count, reinterpret_cast(data)); break; case UniformType::UInt1: case UniformType::UInt2: case UniformType::UInt3: case UniformType::UInt4: - GLSetUniformsUInt(type, location, count, reinterpret_cast(data)); + GLSetUniformUInt(type, location, count, reinterpret_cast(data)); break; case UniformType::Bool1: case UniformType::Bool2: case UniformType::Bool3: case UniformType::Bool4: - GLSetUniformsInt(type, location, count, reinterpret_cast(data)); + GLSetUniformInt(type, location, count, reinterpret_cast(data)); break; /* ----- Matrices ----- */ case UniformType::Float2x2: case UniformType::Float3x3: case UniformType::Float4x4: - GLSetUniformsFloat(type, location, count, reinterpret_cast(data)); + GLSetUniformFloat(type, location, count, reinterpret_cast(data)); break; case UniformType::Float2x3: @@ -246,7 +246,7 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Float3x4: case UniformType::Float4x2: case UniformType::Float4x3: - GLSetUniformsFloatNxM(type, location, count, reinterpret_cast(data)); + GLSetUniformFloatNxM(type, location, count, reinterpret_cast(data)); break; case UniformType::Double2x2: @@ -259,7 +259,7 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Double4x3: case UniformType::Double4x4: #ifdef LLGL_OPENGL - GLSetUniformsDouble(type, location, count, reinterpret_cast(data)); + GLSetUniformDouble(type, location, count, reinterpret_cast(data)); #endif break; @@ -267,23 +267,11 @@ void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const case UniformType::Sampler: case UniformType::Image: case UniformType::AtomicCounter: - GLSetUniformsInt(type, location, count, reinterpret_cast(data)); + GLSetUniformInt(type, location, count, reinterpret_cast(data)); break; } } -void GLSetUniformsByLocation(GLuint program, GLint location, GLsizei count, const void* data) -{ - /* Determine type of uniform */ - GLenum type = 0; - GLint size = 0; - glGetActiveUniform(program, static_cast(location), 0, nullptr, &size, &type, nullptr); - - /* Submit data to respective uniform type */ - UniformType uniformType = GLTypes::UnmapUniformType(type); - GLSetUniformsByType(uniformType, location, count, data); -} - } // /namespace LLGL diff --git a/sources/Renderer/OpenGL/Shader/GLShaderUniform.h b/sources/Renderer/OpenGL/Shader/GLShaderUniform.h index d2d1b7d5c9..de8db7b97b 100644 --- a/sources/Renderer/OpenGL/Shader/GLShaderUniform.h +++ b/sources/Renderer/OpenGL/Shader/GLShaderUniform.h @@ -18,10 +18,7 @@ namespace LLGL // Sets the data of the specified uniform in the active shader program. -void GLSetUniformsByType(UniformType type, GLint location, GLsizei count, const void* data); - -// Sets the data of the specified uniform in the active shader program, where the type is determined by the specified shader program. -void GLSetUniformsByLocation(GLuint program, GLint location, GLsizei count, const void* data); +void GLSetUniform(UniformType type, GLint location, GLsizei count, const void* data); } // /namespace LLGL