From eaac0b0dbea3bb6b09e142af5acb08c316f9367a Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Fri, 15 Apr 2022 18:13:33 +0000 Subject: [PATCH] Uses vertex streams to get attribute locations reducing duplication in XML. Also adds missing streams. This was SVN commit r26792. --- .../data/mods/mod/shaders/glsl/canvas2d.xml | 6 +- binaries/data/mods/mod/shaders/glsl/cas.xml | 12 +- binaries/data/mods/mod/shaders/glsl/fxaa.xml | 12 +- binaries/data/mods/mod/shaders/program.rng | 30 +--- .../data/mods/public/shaders/glsl/bloom.xml | 12 +- .../public/shaders/glsl/debug_overlay.xml | 12 +- .../data/mods/public/shaders/glsl/dof.xml | 12 +- .../data/mods/public/shaders/glsl/dummy.xml | 9 +- .../shaders/glsl/foreground_overlay.xml | 12 +- .../data/mods/public/shaders/glsl/hdr.xml | 12 +- .../mods/public/shaders/glsl/los_interp.xml | 12 +- .../data/mods/public/shaders/glsl/minimap.xml | 15 +- .../mods/public/shaders/glsl/model_common.xml | 24 ++- .../mods/public/shaders/glsl/model_solid.xml | 13 +- .../shaders/glsl/model_solid_player.xml | 13 +- .../public/shaders/glsl/model_solid_tex.xml | 16 +- .../mods/public/shaders/glsl/model_water.xml | 20 +-- .../public/shaders/glsl/model_waterfall.xml | 20 +-- .../public/shaders/glsl/overlay_solid.xml | 8 +- .../mods/public/shaders/glsl/overlayline.xml | 15 +- .../mods/public/shaders/glsl/particle.xml | 18 +-- .../public/shaders/glsl/particle_solid.xml | 18 +-- .../data/mods/public/shaders/glsl/sky.xml | 12 +- .../data/mods/public/shaders/glsl/solid.xml | 9 +- .../mods/public/shaders/glsl/terrain_base.xml | 17 +- .../public/shaders/glsl/terrain_blend.xml | 18 +-- .../public/shaders/glsl/terrain_decal.xml | 17 +- .../mods/public/shaders/glsl/water_high.xml | 11 +- .../mods/public/shaders/glsl/water_simple.xml | 9 +- .../data/mods/public/shaders/glsl/waves.xml | 20 ++- source/renderer/InstancingModelRenderer.cpp | 5 +- source/renderer/backend/gl/ShaderProgram.cpp | 150 ++++++++++-------- source/renderer/backend/gl/ShaderProgram.h | 6 +- 33 files changed, 270 insertions(+), 325 deletions(-) diff --git a/binaries/data/mods/mod/shaders/glsl/canvas2d.xml b/binaries/data/mods/mod/shaders/glsl/canvas2d.xml index 65ea4cd4fc..ffe4fcb2ee 100644 --- a/binaries/data/mods/mod/shaders/glsl/canvas2d.xml +++ b/binaries/data/mods/mod/shaders/glsl/canvas2d.xml @@ -2,10 +2,8 @@ - - - - + + diff --git a/binaries/data/mods/mod/shaders/glsl/cas.xml b/binaries/data/mods/mod/shaders/glsl/cas.xml index 465086d01c..3fc44c20d7 100644 --- a/binaries/data/mods/mod/shaders/glsl/cas.xml +++ b/binaries/data/mods/mod/shaders/glsl/cas.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/mod/shaders/glsl/fxaa.xml b/binaries/data/mods/mod/shaders/glsl/fxaa.xml index 2b044e8129..3d8f4ab627 100644 --- a/binaries/data/mods/mod/shaders/glsl/fxaa.xml +++ b/binaries/data/mods/mod/shaders/glsl/fxaa.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/mod/shaders/program.rng b/binaries/data/mods/mod/shaders/program.rng index 41d7ba76c6..a5580efb02 100644 --- a/binaries/data/mods/mod/shaders/program.rng +++ b/binaries/data/mods/mod/shaders/program.rng @@ -46,28 +46,7 @@ - - - - - - - gl_Vertex - gl_Normal - gl_Color - gl_MultiTexCoord0 - gl_MultiTexCoord1 - gl_MultiTexCoord2 - gl_MultiTexCoord3 - gl_MultiTexCoord4 - gl_MultiTexCoord5 - gl_MultiTexCoord6 - gl_MultiTexCoord7 - - - - - + @@ -115,8 +94,15 @@ uv1 uv2 uv3 + uv4 + uv5 + uv6 + uv7 + + + diff --git a/binaries/data/mods/public/shaders/glsl/bloom.xml b/binaries/data/mods/public/shaders/glsl/bloom.xml index 7815267748..e3981db55c 100644 --- a/binaries/data/mods/public/shaders/glsl/bloom.xml +++ b/binaries/data/mods/public/shaders/glsl/bloom.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/debug_overlay.xml b/binaries/data/mods/public/shaders/glsl/debug_overlay.xml index 5c92af6f60..c0b5592f5c 100644 --- a/binaries/data/mods/public/shaders/glsl/debug_overlay.xml +++ b/binaries/data/mods/public/shaders/glsl/debug_overlay.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/dof.xml b/binaries/data/mods/public/shaders/glsl/dof.xml index 873d0d874b..99750253ce 100644 --- a/binaries/data/mods/public/shaders/glsl/dof.xml +++ b/binaries/data/mods/public/shaders/glsl/dof.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/dummy.xml b/binaries/data/mods/public/shaders/glsl/dummy.xml index d494585171..5aa4c405a0 100644 --- a/binaries/data/mods/public/shaders/glsl/dummy.xml +++ b/binaries/data/mods/public/shaders/glsl/dummy.xml @@ -1,11 +1,10 @@ - - - - + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml b/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml index d6759eb55b..126641e1ff 100644 --- a/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml +++ b/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/hdr.xml b/binaries/data/mods/public/shaders/glsl/hdr.xml index 9f2d97ec5a..c16166c082 100644 --- a/binaries/data/mods/public/shaders/glsl/hdr.xml +++ b/binaries/data/mods/public/shaders/glsl/hdr.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/los_interp.xml b/binaries/data/mods/public/shaders/glsl/los_interp.xml index d146d441c0..7a4ab69efb 100644 --- a/binaries/data/mods/public/shaders/glsl/los_interp.xml +++ b/binaries/data/mods/public/shaders/glsl/los_interp.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/minimap.xml b/binaries/data/mods/public/shaders/glsl/minimap.xml index f9fc8e6fc2..6dd18a70bb 100644 --- a/binaries/data/mods/public/shaders/glsl/minimap.xml +++ b/binaries/data/mods/public/shaders/glsl/minimap.xml @@ -1,15 +1,12 @@ - - - - - - - - + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_common.xml b/binaries/data/mods/public/shaders/glsl/model_common.xml index fe90adb8a6..17ababd31a 100644 --- a/binaries/data/mods/public/shaders/glsl/model_common.xml +++ b/binaries/data/mods/public/shaders/glsl/model_common.xml @@ -1,20 +1,16 @@ - - - - - - - - - - - - - + + + + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_solid.xml b/binaries/data/mods/public/shaders/glsl/model_solid.xml index bb65d5cffc..8739efbede 100644 --- a/binaries/data/mods/public/shaders/glsl/model_solid.xml +++ b/binaries/data/mods/public/shaders/glsl/model_solid.xml @@ -1,13 +1,12 @@ - - - - - - + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_solid_player.xml b/binaries/data/mods/public/shaders/glsl/model_solid_player.xml index d4e12ea506..045a13f883 100644 --- a/binaries/data/mods/public/shaders/glsl/model_solid_player.xml +++ b/binaries/data/mods/public/shaders/glsl/model_solid_player.xml @@ -1,13 +1,12 @@ - - - - - - + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_solid_tex.xml b/binaries/data/mods/public/shaders/glsl/model_solid_tex.xml index 338c1fa20e..9f195d5db5 100644 --- a/binaries/data/mods/public/shaders/glsl/model_solid_tex.xml +++ b/binaries/data/mods/public/shaders/glsl/model_solid_tex.xml @@ -1,15 +1,13 @@ - - - - - - - - + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_water.xml b/binaries/data/mods/public/shaders/glsl/model_water.xml index fe4d1bceb6..43ea2ca0e6 100644 --- a/binaries/data/mods/public/shaders/glsl/model_water.xml +++ b/binaries/data/mods/public/shaders/glsl/model_water.xml @@ -1,18 +1,14 @@ - - - - - - - - - - - + + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/model_waterfall.xml b/binaries/data/mods/public/shaders/glsl/model_waterfall.xml index e5ea48f009..0521251e63 100644 --- a/binaries/data/mods/public/shaders/glsl/model_waterfall.xml +++ b/binaries/data/mods/public/shaders/glsl/model_waterfall.xml @@ -1,18 +1,14 @@ - - - - - - - - - - - + + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/overlay_solid.xml b/binaries/data/mods/public/shaders/glsl/overlay_solid.xml index 4fad59699a..90658744eb 100644 --- a/binaries/data/mods/public/shaders/glsl/overlay_solid.xml +++ b/binaries/data/mods/public/shaders/glsl/overlay_solid.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/binaries/data/mods/public/shaders/glsl/overlayline.xml b/binaries/data/mods/public/shaders/glsl/overlayline.xml index 8ef42221e6..a39fc86c10 100644 --- a/binaries/data/mods/public/shaders/glsl/overlayline.xml +++ b/binaries/data/mods/public/shaders/glsl/overlayline.xml @@ -1,15 +1,12 @@ - - - - - - - - + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/particle.xml b/binaries/data/mods/public/shaders/glsl/particle.xml index cda69e5cf2..523a2db746 100644 --- a/binaries/data/mods/public/shaders/glsl/particle.xml +++ b/binaries/data/mods/public/shaders/glsl/particle.xml @@ -1,17 +1,13 @@ - - - - - - - - - - + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/particle_solid.xml b/binaries/data/mods/public/shaders/glsl/particle_solid.xml index cda69e5cf2..523a2db746 100644 --- a/binaries/data/mods/public/shaders/glsl/particle_solid.xml +++ b/binaries/data/mods/public/shaders/glsl/particle_solid.xml @@ -1,17 +1,13 @@ - - - - - - - - - - + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/sky.xml b/binaries/data/mods/public/shaders/glsl/sky.xml index 436bbef4a3..004700e1d2 100644 --- a/binaries/data/mods/public/shaders/glsl/sky.xml +++ b/binaries/data/mods/public/shaders/glsl/sky.xml @@ -1,13 +1,11 @@ - - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/solid.xml b/binaries/data/mods/public/shaders/glsl/solid.xml index 3670d41aa8..522fab8747 100644 --- a/binaries/data/mods/public/shaders/glsl/solid.xml +++ b/binaries/data/mods/public/shaders/glsl/solid.xml @@ -1,11 +1,10 @@ - - - - + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/terrain_base.xml b/binaries/data/mods/public/shaders/glsl/terrain_base.xml index 73e3bde37f..8bc7050399 100644 --- a/binaries/data/mods/public/shaders/glsl/terrain_base.xml +++ b/binaries/data/mods/public/shaders/glsl/terrain_base.xml @@ -1,16 +1,13 @@ - - - - - - - - - + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/terrain_blend.xml b/binaries/data/mods/public/shaders/glsl/terrain_blend.xml index 04c2d9c5a1..c74c581f7c 100644 --- a/binaries/data/mods/public/shaders/glsl/terrain_blend.xml +++ b/binaries/data/mods/public/shaders/glsl/terrain_blend.xml @@ -1,17 +1,15 @@ - + - - - - - - - - + + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/terrain_decal.xml b/binaries/data/mods/public/shaders/glsl/terrain_decal.xml index 5929077463..8cd7841882 100644 --- a/binaries/data/mods/public/shaders/glsl/terrain_decal.xml +++ b/binaries/data/mods/public/shaders/glsl/terrain_decal.xml @@ -1,17 +1,14 @@ - + - - - - - - - - + + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/water_high.xml b/binaries/data/mods/public/shaders/glsl/water_high.xml index 2bd55be5dd..90b0298708 100644 --- a/binaries/data/mods/public/shaders/glsl/water_high.xml +++ b/binaries/data/mods/public/shaders/glsl/water_high.xml @@ -1,12 +1,11 @@ - - - - - + + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/water_simple.xml b/binaries/data/mods/public/shaders/glsl/water_simple.xml index 78a86b875b..0eedbf0301 100644 --- a/binaries/data/mods/public/shaders/glsl/water_simple.xml +++ b/binaries/data/mods/public/shaders/glsl/water_simple.xml @@ -1,11 +1,10 @@ - - - - + + + - + diff --git a/binaries/data/mods/public/shaders/glsl/waves.xml b/binaries/data/mods/public/shaders/glsl/waves.xml index 6f535ee105..c0c4c0b4c5 100644 --- a/binaries/data/mods/public/shaders/glsl/waves.xml +++ b/binaries/data/mods/public/shaders/glsl/waves.xml @@ -1,17 +1,15 @@ - - - - - - - - - - + + + + + + + + - + diff --git a/source/renderer/InstancingModelRenderer.cpp b/source/renderer/InstancingModelRenderer.cpp index 304e022a85..294014e6ed 100644 --- a/source/renderer/InstancingModelRenderer.cpp +++ b/source/renderer/InstancingModelRenderer.cpp @@ -297,7 +297,7 @@ void InstancingModelRenderer::UpdateModelData(CModel* UNUSED(model), CModelRData // Setup one rendering pass. void InstancingModelRenderer::BeginPass(int streamflags) { - ENSURE(streamflags == (streamflags & (STREAM_POS|STREAM_NORMAL|STREAM_UV0|STREAM_UV1))); + ENSURE(streamflags == (streamflags & (STREAM_POS|STREAM_NORMAL|STREAM_UV0|STREAM_UV1|STREAM_UV2|STREAM_UV3|STREAM_UV4))); } // Cleanup rendering pass. @@ -345,8 +345,7 @@ void InstancingModelRenderer::PrepareModelDef( GL_FALSE, stride, base + m->imodeldef->m_Tangent.offset); } - // The last UV set is STREAM_UV3 - for (size_t uv = 0; uv < 4; ++uv) + for (size_t uv = 0; uv < 2; ++uv) if (streamflags & (STREAM_UV0 << uv)) { if (def.GetNumUVsPerVertex() >= uv + 1) diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index 6bda3e8360..e3d98484f9 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -100,41 +100,47 @@ GLenum GLTypeFromFormat(const Renderer::Backend::Format format) return type; } -int ParseAttribSemantics(Renderer::Backend::GL::CDevice* device, const CStr& str) +int GetAttributeLocationFromStream(Renderer::Backend::GL::CDevice* device, const int stream) { // Old mapping makes sense only if we have an old/low-end hardware. Else we // need to use sequential numbering to fix #3054. We use presence of // compute shaders as a check that the hardware has universal CUs. if (device->GetCapabilities().computeShaders) { - if (str == "gl_Vertex") return 0; - if (str == "gl_Normal") return 1; - if (str == "gl_Color") return 2; - if (str == "gl_MultiTexCoord0") return 3; - if (str == "gl_MultiTexCoord1") return 4; - if (str == "gl_MultiTexCoord2") return 5; - if (str == "gl_MultiTexCoord3") return 6; - if (str == "gl_MultiTexCoord4") return 7; - if (str == "gl_MultiTexCoord5") return 8; - if (str == "gl_MultiTexCoord6") return 9; - if (str == "gl_MultiTexCoord7") return 10; + switch (stream) + { + case STREAM_POS: return 0; + case STREAM_NORMAL: return 1; + case STREAM_COLOR: return 2; + case STREAM_UV0: return 3; + case STREAM_UV1: return 4; + case STREAM_UV2: return 5; + case STREAM_UV3: return 6; + case STREAM_UV4: return 7; + case STREAM_UV5: return 8; + case STREAM_UV6: return 9; + case STREAM_UV7: return 10; + } } else { // Map known semantics onto the attribute locations documented by NVIDIA: // https://download.nvidia.com/developer/Papers/2005/OpenGL_2.0/NVIDIA_OpenGL_2.0_Support.pdf // https://developer.download.nvidia.com/opengl/glsl/glsl_release_notes.pdf - if (str == "gl_Vertex") return 0; - if (str == "gl_Normal") return 2; - if (str == "gl_Color") return 3; - if (str == "gl_MultiTexCoord0") return 8; - if (str == "gl_MultiTexCoord1") return 9; - if (str == "gl_MultiTexCoord2") return 10; - if (str == "gl_MultiTexCoord3") return 11; - if (str == "gl_MultiTexCoord4") return 12; - if (str == "gl_MultiTexCoord5") return 13; - if (str == "gl_MultiTexCoord6") return 14; - if (str == "gl_MultiTexCoord7") return 15; + switch (stream) + { + case STREAM_POS: return 0; + case STREAM_NORMAL: return 2; + case STREAM_COLOR: return 3; + case STREAM_UV0: return 8; + case STREAM_UV1: return 9; + case STREAM_UV2: return 10; + case STREAM_UV3: return 11; + case STREAM_UV4: return 12; + case STREAM_UV5: return 13; + case STREAM_UV6: return 14; + case STREAM_UV7: return 15; + } } debug_warn("Invalid attribute semantics"); @@ -815,6 +821,7 @@ public: const GLint size = GLSizeFromFormat(format); const GLenum type = GLTypeFromFormat(format); glVertexAttribPointer(it->second, size, type, normalized, stride, pointer); + m_ValidStreams |= STREAM_UV0 << (it->second - (m_Device->GetCapabilities().computeShaders ? 3 : 8)); } } @@ -875,17 +882,16 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS // Define all the elements and attributes used in the XML file #define EL(x) int el_##x = XeroFile.GetElementID(#x) #define AT(x) int at_##x = XeroFile.GetAttributeID(#x) - EL(attrib); EL(define); EL(fragment); EL(stream); EL(uniform); EL(vertex); + AT(attribute); AT(file); AT(if); AT(loc); AT(name); - AT(semantics); AT(type); AT(value); #undef AT @@ -904,72 +910,86 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS std::map vertexAttribs; int streamFlags = 0; - XERO_ITER_EL(root, Child) + XERO_ITER_EL(root, child) { - if (Child.GetNodeName() == el_define) + if (child.GetNodeName() == el_define) { - defines.Add(CStrIntern(Child.GetAttributes().GetNamedItem(at_name)), CStrIntern(Child.GetAttributes().GetNamedItem(at_value))); + defines.Add(CStrIntern(child.GetAttributes().GetNamedItem(at_name)), CStrIntern(child.GetAttributes().GetNamedItem(at_value))); } - else if (Child.GetNodeName() == el_vertex) + else if (child.GetNodeName() == el_vertex) { - vertexFile = L"shaders/" + Child.GetAttributes().GetNamedItem(at_file).FromUTF8(); + vertexFile = L"shaders/" + child.GetAttributes().GetNamedItem(at_file).FromUTF8(); - XERO_ITER_EL(Child, Param) + XERO_ITER_EL(child, param) { - XMBAttributeList Attrs = Param.GetAttributes(); + XMBAttributeList attributes = param.GetAttributes(); - CStr cond = Attrs.GetNamedItem(at_if); + CStr cond = attributes.GetNamedItem(at_if); if (!cond.empty() && !preprocessor.TestConditional(cond)) continue; - if (Param.GetNodeName() == el_uniform) + if (param.GetNodeName() == el_uniform) { - vertexUniforms[CStrIntern(Attrs.GetNamedItem(at_name))] = Attrs.GetNamedItem(at_loc).ToInt(); + vertexUniforms[CStrIntern(attributes.GetNamedItem(at_name))] = attributes.GetNamedItem(at_loc).ToInt(); } - else if (Param.GetNodeName() == el_stream) + else if (param.GetNodeName() == el_stream) { - CStr StreamName = Attrs.GetNamedItem(at_name); - if (StreamName == "pos") - streamFlags |= STREAM_POS; - else if (StreamName == "normal") - streamFlags |= STREAM_NORMAL; - else if (StreamName == "color") - streamFlags |= STREAM_COLOR; - else if (StreamName == "uv0") - streamFlags |= STREAM_UV0; - else if (StreamName == "uv1") - streamFlags |= STREAM_UV1; - else if (StreamName == "uv2") - streamFlags |= STREAM_UV2; - else if (StreamName == "uv3") - streamFlags |= STREAM_UV3; - } - else if (Param.GetNodeName() == el_attrib) - { - const int attribLoc = ParseAttribSemantics(device, Attrs.GetNamedItem(at_semantics)); - vertexAttribs[CStrIntern(Attrs.GetNamedItem(at_name))] = attribLoc; + const CStr streamName = attributes.GetNamedItem(at_name); + const CStr attributeName = attributes.GetNamedItem(at_attribute); + if (attributeName.empty()) + LOGERROR("Empty attribute name in vertex shader description '%s'", vertexFile.string8().c_str()); + + int stream = 0; + if (streamName == "pos") + stream = STREAM_POS; + else if (streamName == "normal") + stream = STREAM_NORMAL; + else if (streamName == "color") + stream = STREAM_COLOR; + else if (streamName == "uv0") + stream = STREAM_UV0; + else if (streamName == "uv1") + stream = STREAM_UV1; + else if (streamName == "uv2") + stream = STREAM_UV2; + else if (streamName == "uv3") + stream = STREAM_UV3; + else if (streamName == "uv4") + stream = STREAM_UV4; + else if (streamName == "uv5") + stream = STREAM_UV5; + else if (streamName == "uv6") + stream = STREAM_UV6; + else if (streamName == "uv7") + stream = STREAM_UV7; + else + LOGERROR("Unknown stream '%s' in vertex shader description '%s'", streamName.c_str(), vertexFile.string8().c_str()); + + const int attributeLocation = GetAttributeLocationFromStream(device, stream); + vertexAttribs[CStrIntern(attributeName)] = attributeLocation; + streamFlags |= stream; } } } - else if (Child.GetNodeName() == el_fragment) + else if (child.GetNodeName() == el_fragment) { - fragmentFile = L"shaders/" + Child.GetAttributes().GetNamedItem(at_file).FromUTF8(); + fragmentFile = L"shaders/" + child.GetAttributes().GetNamedItem(at_file).FromUTF8(); - XERO_ITER_EL(Child, Param) + XERO_ITER_EL(child, param) { - XMBAttributeList Attrs = Param.GetAttributes(); + XMBAttributeList attributes = param.GetAttributes(); - CStr cond = Attrs.GetNamedItem(at_if); + CStr cond = attributes.GetNamedItem(at_if); if (!cond.empty() && !preprocessor.TestConditional(cond)) continue; - if (Param.GetNodeName() == el_uniform) + if (param.GetNodeName() == el_uniform) { // A somewhat incomplete listing, missing "shadow" and "rect" versions // which are interpreted as 2D (NB: our shadowmaps may change // type based on user config). GLenum type = GL_TEXTURE_2D; - CStr t = Attrs.GetNamedItem(at_type); + const CStr t = attributes.GetNamedItem(at_type); if (t == "sampler1D") #if CONFIG2_GLES debug_warn(L"sampler1D not implemented on GLES"); @@ -987,8 +1007,8 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS else if (t == "samplerCube") type = GL_TEXTURE_CUBE_MAP; - fragmentUniforms[CStrIntern(Attrs.GetNamedItem(at_name))] = - std::make_pair(Attrs.GetNamedItem(at_loc).ToInt(), type); + fragmentUniforms[CStrIntern(attributes.GetNamedItem(at_name))] = + std::make_pair(attributes.GetNamedItem(at_loc).ToInt(), type); } } } diff --git a/source/renderer/backend/gl/ShaderProgram.h b/source/renderer/backend/gl/ShaderProgram.h index d6ad5ff994..5ec5209324 100644 --- a/source/renderer/backend/gl/ShaderProgram.h +++ b/source/renderer/backend/gl/ShaderProgram.h @@ -43,7 +43,11 @@ enum STREAM_UV0 = (1 << 3), STREAM_UV1 = (1 << 4), STREAM_UV2 = (1 << 5), - STREAM_UV3 = (1 << 6) + STREAM_UV3 = (1 << 6), + STREAM_UV4 = (1 << 7), + STREAM_UV5 = (1 << 8), + STREAM_UV6 = (1 << 9), + STREAM_UV7 = (1 << 10), }; namespace Renderer