summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-08-11 20:36:40 -0500
committerGravatar Subv2018-08-11 20:36:40 -0500
commit2dad1204e857259e65e50880c7416606c8382b2d (patch)
tree1dd40e5540b56198fc64437eacdbdc2981396f82 /src
parentMerge pull request #1010 from bunnei/unk-vert-attrib-shader (diff)
downloadyuzu-2dad1204e857259e65e50880c7416606c8382b2d.tar.gz
yuzu-2dad1204e857259e65e50880c7416606c8382b2d.tar.xz
yuzu-2dad1204e857259e65e50880c7416606c8382b2d.zip
RasterizerGL: Ignore invalid/unset vertex attributes.
This should make the es2gears example not crash anymore.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.h5
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 0506ac8fe..d795323b0 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -93,6 +93,7 @@ public:
93 93
94 struct VertexAttribute { 94 struct VertexAttribute {
95 enum class Size : u32 { 95 enum class Size : u32 {
96 Invalid = 0x0,
96 Size_32_32_32_32 = 0x01, 97 Size_32_32_32_32 = 0x01,
97 Size_32_32_32 = 0x02, 98 Size_32_32_32 = 0x02,
98 Size_16_16_16_16 = 0x03, 99 Size_16_16_16_16 = 0x03,
@@ -257,6 +258,10 @@ public:
257 bool IsNormalized() const { 258 bool IsNormalized() const {
258 return (type == Type::SignedNorm) || (type == Type::UnsignedNorm); 259 return (type == Type::SignedNorm) || (type == Type::UnsignedNorm);
259 } 260 }
261
262 bool IsValid() const {
263 return size != Size::Invalid;
264 }
260 }; 265 };
261 266
262 enum class PrimitiveTopology : u32 { 267 enum class PrimitiveTopology : u32 {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 8360feb5d..3646a1b1b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -161,11 +161,16 @@ std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
161 // assume every shader uses them all. 161 // assume every shader uses them all.
162 for (unsigned index = 0; index < 16; ++index) { 162 for (unsigned index = 0; index < 16; ++index) {
163 auto& attrib = regs.vertex_attrib_format[index]; 163 auto& attrib = regs.vertex_attrib_format[index];
164
165 // Ignore invalid attributes.
166 if (!attrib.IsValid())
167 continue;
168
169 auto& buffer = regs.vertex_array[attrib.buffer];
164 LOG_TRACE(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}", 170 LOG_TRACE(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}",
165 index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(), 171 index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(),
166 attrib.offset.Value(), attrib.IsNormalized()); 172 attrib.offset.Value(), attrib.IsNormalized());
167 173
168 auto& buffer = regs.vertex_array[attrib.buffer];
169 ASSERT(buffer.IsEnabled()); 174 ASSERT(buffer.IsEnabled());
170 175
171 glEnableVertexAttribArray(index); 176 glEnableVertexAttribArray(index);