diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2017-06-04 18:30:17 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2017-07-17 01:21:02 -0700 |
commit | 5b3c61fb00c35fb8c16d1cf26a65b1f0542416a0 (patch) | |
tree | 6b354ad4d6be77fe7146a30c91b3d00b7814ec6a | |
parent | 60e7437ae54652a7daf1fd1868a9641e5ce54577 (diff) |
Respect GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT in binding-layout.c.
The spec/arb_shading_language_420pack/execution/binding-layout test
assumed that it could bind buffers at 16-byte offsets. This may not
be true - we need to respect GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.
This prevents crashes on drivers which require an alignment larger than
16 bytes. The closed source AMD and NVIDIA drivers appear to require
an alignment of 256 bytes, and I have a patch to bump i965 to 32 bytes.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r-- | tests/spec/arb_shading_language_420pack/execution/binding-layout.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/spec/arb_shading_language_420pack/execution/binding-layout.c b/tests/spec/arb_shading_language_420pack/execution/binding-layout.c index bda43dd0d..acbb8f4dd 100644 --- a/tests/spec/arb_shading_language_420pack/execution/binding-layout.c +++ b/tests/spec/arb_shading_language_420pack/execution/binding-layout.c @@ -152,6 +152,7 @@ piglit_init(int argc, char **argv) }; bool pass = true; GLuint bo; + GLint alignment; piglit_require_extension("GL_ARB_shading_language_420pack"); piglit_require_extension("GL_ARB_explicit_attrib_location"); @@ -167,14 +168,21 @@ piglit_init(int argc, char **argv) if (!pass) piglit_report_result(PIGLIT_FAIL); + /* Pad out to the alignment or the size of a vec4. */ + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment); + alignment = MAX2(alignment, 4 * sizeof(float)); + glGenBuffers(1, &bo); glBindBuffer(GL_UNIFORM_BUFFER, bo); - glBufferData(GL_UNIFORM_BUFFER, sizeof(data), data, GL_STATIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, 3 * alignment, NULL, GL_STATIC_DRAW); + glBufferSubData(GL_UNIFORM_BUFFER, 0 * alignment, 16, &data[0]); + glBufferSubData(GL_UNIFORM_BUFFER, 1 * alignment, 16, &data[4]); + glBufferSubData(GL_UNIFORM_BUFFER, 2 * alignment, 16, &data[8]); glBindBuffer(GL_UNIFORM_BUFFER, 0); - glBindBufferRange(GL_UNIFORM_BUFFER, 2, bo, 0, 16); - glBindBufferRange(GL_UNIFORM_BUFFER, 3, bo, 16, 16); - glBindBufferRange(GL_UNIFORM_BUFFER, 4, bo, 32, 16); + glBindBufferRange(GL_UNIFORM_BUFFER, 2, bo, 0 * alignment, 16); + glBindBufferRange(GL_UNIFORM_BUFFER, 3, bo, 1 * alignment, 16); + glBindBufferRange(GL_UNIFORM_BUFFER, 4, bo, 2 * alignment, 16); glClearColor(0.5, 0.5, 0.5, 1.0); } |