Typeify VertexBufferSlot and VertexAttributeLocation
Bug: dawn:442
Change-Id: Ic4c29eed51984d367dc7fd6055e33d26bfc7faed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28041
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/opengl/RenderPipelineGL.cpp b/src/dawn_native/opengl/RenderPipelineGL.cpp
index 5130e59..f176cd6 100644
--- a/src/dawn_native/opengl/RenderPipelineGL.cpp
+++ b/src/dawn_native/opengl/RenderPipelineGL.cpp
@@ -218,29 +218,36 @@
return mGlPrimitiveTopology;
}
+ ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>
+ RenderPipeline::GetAttributesUsingVertexBuffer(VertexBufferSlot slot) const {
+ ASSERT(!IsError());
+ return mAttributesUsingVertexBuffer[slot];
+ }
+
void RenderPipeline::CreateVAOForVertexState(const VertexStateDescriptor* vertexState) {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
gl.GenVertexArrays(1, &mVertexArrayObject);
gl.BindVertexArray(mVertexArrayObject);
- for (uint32_t location : IterateBitSet(GetAttributeLocationsUsed())) {
+ for (VertexAttributeLocation location : IterateBitSet(GetAttributeLocationsUsed())) {
const auto& attribute = GetAttribute(location);
- gl.EnableVertexAttribArray(location);
+ GLuint glAttrib = static_cast<GLuint>(static_cast<uint8_t>(location));
+ gl.EnableVertexAttribArray(glAttrib);
- attributesUsingVertexBuffer[attribute.vertexBufferSlot][location] = true;
+ mAttributesUsingVertexBuffer[attribute.vertexBufferSlot][location] = true;
const VertexBufferInfo& vertexBuffer = GetVertexBuffer(attribute.vertexBufferSlot);
if (vertexBuffer.arrayStride == 0) {
// Emulate a stride of zero (constant vertex attribute) by
// setting the attribute instance divisor to a huge number.
- gl.VertexAttribDivisor(location, 0xffffffff);
+ gl.VertexAttribDivisor(glAttrib, 0xffffffff);
} else {
switch (vertexBuffer.stepMode) {
case wgpu::InputStepMode::Vertex:
break;
case wgpu::InputStepMode::Instance:
- gl.VertexAttribDivisor(location, 1);
+ gl.VertexAttribDivisor(glAttrib, 1);
break;
default:
UNREACHABLE();