diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index cbc629a561..9f6b048d0e 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -1179,7 +1179,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last } for (size_t i = 0; i < layout->entries.size(); i++) { auto &entry = layout->entries[i]; - glVertexAttribPointer(entry.location, entry.count, entry.type, entry.normalized, entry.stride, (const void *)(c.draw.offset + entry.offset)); + glVertexAttribPointer(entry.location, entry.count, entry.type, entry.normalized, layout->stride, (const void *)(c.draw.offset + entry.offset)); } if (c.draw.indexBuffer) { GLuint buf = c.draw.indexBuffer->buffer_; diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index a926dcd41f..6b7010d284 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -359,10 +359,10 @@ public: int count; GLenum type; GLboolean normalized; - int stride; intptr_t offset; }; std::vector entries; + int stride; int semanticsMask_ = 0; }; @@ -487,10 +487,11 @@ public: return step.create_program.program; } - GLRInputLayout *CreateInputLayout(const std::vector &entries) { + GLRInputLayout *CreateInputLayout(const std::vector &entries, int stride) { GLRInitStep step{ GLRInitStepType::CREATE_INPUT_LAYOUT }; step.create_input_layout.inputLayout = new GLRInputLayout(); step.create_input_layout.inputLayout->entries = entries; + step.create_input_layout.inputLayout->stride = stride; for (auto &iter : step.create_input_layout.inputLayout->entries) { step.create_input_layout.inputLayout->semanticsMask_ |= 1 << iter.location; } diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 926bd78aea..d9b8a189fb 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -1393,13 +1393,13 @@ OpenGLInputLayout::~OpenGLInputLayout() { void OpenGLInputLayout::Compile(const InputLayoutDesc &desc) { // TODO: This is only accurate if there's only one stream. But whatever, for now we // never use multiple streams anyway. - stride = desc.bindings.empty() ? 0 : (GLsizei)desc.bindings[0].stride; + _dbg_assert_(desc.bindings.size() == 1); + stride = (GLsizei)desc.bindings[0].stride; std::vector entries; for (auto &attr : desc.attributes) { GLRInputLayout::Entry entry; entry.location = attr.location; - entry.stride = (GLsizei)desc.bindings[attr.binding].stride; entry.offset = attr.offset; switch (attr.format) { case DataFormat::R32G32_FLOAT: @@ -1431,7 +1431,7 @@ void OpenGLInputLayout::Compile(const InputLayoutDesc &desc) { entries.push_back(entry); } if (!entries.empty()) { - inputLayout_ = render_->CreateInputLayout(entries); + inputLayout_ = render_->CreateInputLayout(entries, stride); } else { inputLayout_ = nullptr; } diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 0ea95fbffe..76ec0dd3f7 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -103,12 +103,12 @@ void DrawEngineGLES::InitDeviceObjects() { int vertexSize = sizeof(TransformedVertex); std::vector entries; - entries.push_back({ ATTR_POSITION, 4, GL_FLOAT, GL_FALSE, vertexSize, offsetof(TransformedVertex, x) }); - entries.push_back({ ATTR_TEXCOORD, 3, GL_FLOAT, GL_FALSE, vertexSize, offsetof(TransformedVertex, u) }); - entries.push_back({ ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, offsetof(TransformedVertex, color0) }); - entries.push_back({ ATTR_COLOR1, 3, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, offsetof(TransformedVertex, color1) }); - entries.push_back({ ATTR_NORMAL, 1, GL_FLOAT, GL_FALSE, vertexSize, offsetof(TransformedVertex, fog) }); - softwareInputLayout_ = render_->CreateInputLayout(entries); + entries.push_back({ ATTR_POSITION, 4, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, x) }); + entries.push_back({ ATTR_TEXCOORD, 3, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, u) }); + entries.push_back({ ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, offsetof(TransformedVertex, color0) }); + entries.push_back({ ATTR_COLOR1, 3, GL_UNSIGNED_BYTE, GL_TRUE, offsetof(TransformedVertex, color1) }); + entries.push_back({ ATTR_NORMAL, 1, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, fog) }); + softwareInputLayout_ = render_->CreateInputLayout(entries, vertexSize); draw_->SetInvalidationCallback(std::bind(&DrawEngineGLES::Invalidate, this, std::placeholders::_1)); } @@ -189,7 +189,7 @@ static const GlTypeInfo GLComp[] = { {GL_UNSIGNED_SHORT, 4, GL_TRUE},// DEC_U16_4, }; -static inline void VertexAttribSetup(int attrib, int fmt, int stride, int offset, std::vector &entries) { +static inline void VertexAttribSetup(int attrib, int fmt, int offset, std::vector &entries) { if (fmt) { const GlTypeInfo &type = GLComp[fmt]; GLRInputLayout::Entry entry; @@ -197,7 +197,6 @@ static inline void VertexAttribSetup(int attrib, int fmt, int stride, int offset entry.location = attrib; entry.normalized = type.normalized; entry.type = type.type; - entry.stride = stride; entry.count = type.count; entries.push_back(entry); } @@ -212,15 +211,15 @@ GLRInputLayout *DrawEngineGLES::SetupDecFmtForDraw(LinkedShader *program, const } std::vector entries; - VertexAttribSetup(ATTR_W1, decFmt.w0fmt, decFmt.stride, decFmt.w0off, entries); - VertexAttribSetup(ATTR_W2, decFmt.w1fmt, decFmt.stride, decFmt.w1off, entries); - VertexAttribSetup(ATTR_TEXCOORD, decFmt.uvfmt, decFmt.stride, decFmt.uvoff, entries); - VertexAttribSetup(ATTR_COLOR0, decFmt.c0fmt, decFmt.stride, decFmt.c0off, entries); - VertexAttribSetup(ATTR_COLOR1, decFmt.c1fmt, decFmt.stride, decFmt.c1off, entries); - VertexAttribSetup(ATTR_NORMAL, decFmt.nrmfmt, decFmt.stride, decFmt.nrmoff, entries); - VertexAttribSetup(ATTR_POSITION, decFmt.posfmt, decFmt.stride, decFmt.posoff, entries); + VertexAttribSetup(ATTR_W1, decFmt.w0fmt, decFmt.w0off, entries); + VertexAttribSetup(ATTR_W2, decFmt.w1fmt, decFmt.w1off, entries); + VertexAttribSetup(ATTR_TEXCOORD, decFmt.uvfmt, decFmt.uvoff, entries); + VertexAttribSetup(ATTR_COLOR0, decFmt.c0fmt, decFmt.c0off, entries); + VertexAttribSetup(ATTR_COLOR1, decFmt.c1fmt, decFmt.c1off, entries); + VertexAttribSetup(ATTR_NORMAL, decFmt.nrmfmt, decFmt.nrmoff, entries); + VertexAttribSetup(ATTR_POSITION, decFmt.posfmt, decFmt.posoff, entries); - inputLayout = render_->CreateInputLayout(entries); + inputLayout = render_->CreateInputLayout(entries, decFmt.stride); inputLayoutMap_.Insert(key, inputLayout); return inputLayout; }