diff options
author | Timothy Arceri <[email protected]> | 2016-11-22 20:24:33 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-01-19 17:05:26 +1100 |
commit | 4d65f68a9bd225133897bc56c89a0fa9baf6d672 (patch) | |
tree | 65c5d9ee0283d14922df351d9ea80561e218c3bf /src/compiler/glsl/linker.cpp | |
parent | e603cf18415adba5f9e879aba3c1146e952eb688 (diff) |
mesa/glsl: move TransformFeedbackBufferStride to gl_shader
Here we remove the single use of this field in gl_linked_shader
which allows us to move the field out of gl_shader_info
While we are at it we rewrite link_xfb_stride_layout_qualifiers()
to be more clear.
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/glsl/linker.cpp')
-rw-r--r-- | src/compiler/glsl/linker.cpp | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 35f1d8b6a8e..61dfa556810 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1587,6 +1587,29 @@ private: hash_table *unnamed_interfaces; }; +static bool +validate_xfb_buffer_stride(struct gl_context *ctx, unsigned idx, + struct gl_shader_program *prog) +{ + /* We will validate doubles at a later stage */ + if (prog->TransformFeedback.BufferStride[idx] % 4) { + linker_error(prog, "invalid qualifier xfb_stride=%d must be a " + "multiple of 4 or if its applied to a type that is " + "or contains a double a multiple of 8.", + prog->TransformFeedback.BufferStride[idx]); + return false; + } + + if (prog->TransformFeedback.BufferStride[idx] / 4 > + ctx->Const.MaxTransformFeedbackInterleavedComponents) { + linker_error(prog, "The MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS " + "limit has been exceeded."); + return false; + } + + return true; +} + /** * Check for conflicting xfb_stride default qualifiers and store buffer stride * for later use. @@ -1599,54 +1622,28 @@ link_xfb_stride_layout_qualifiers(struct gl_context *ctx, unsigned num_shaders) { for (unsigned i = 0; i < MAX_FEEDBACK_BUFFERS; i++) { - linked_shader->info.TransformFeedback.BufferStride[i] = 0; + prog->TransformFeedback.BufferStride[i] = 0; } for (unsigned i = 0; i < num_shaders; i++) { struct gl_shader *shader = shader_list[i]; for (unsigned j = 0; j < MAX_FEEDBACK_BUFFERS; j++) { - if (shader->info.TransformFeedback.BufferStride[j]) { - if (linked_shader->info.TransformFeedback.BufferStride[j] != 0 && - shader->info.TransformFeedback.BufferStride[j] != 0 && - linked_shader->info.TransformFeedback.BufferStride[j] != - shader->info.TransformFeedback.BufferStride[j]) { + if (shader->TransformFeedbackBufferStride[j]) { + if (prog->TransformFeedback.BufferStride[j] == 0) { + prog->TransformFeedback.BufferStride[j] = + shader->TransformFeedbackBufferStride[j]; + if (!validate_xfb_buffer_stride(ctx, j, prog)) + return; + } else if (prog->TransformFeedback.BufferStride[j] != + shader->TransformFeedbackBufferStride[j]){ linker_error(prog, "intrastage shaders defined with conflicting " "xfb_stride for buffer %d (%d and %d)\n", j, - linked_shader-> - info.TransformFeedback.BufferStride[j], - shader->info.TransformFeedback.BufferStride[j]); + prog->TransformFeedback.BufferStride[j], + shader->TransformFeedbackBufferStride[j]); return; } - - if (shader->info.TransformFeedback.BufferStride[j]) - linked_shader->info.TransformFeedback.BufferStride[j] = - shader->info.TransformFeedback.BufferStride[j]; - } - } - } - - for (unsigned j = 0; j < MAX_FEEDBACK_BUFFERS; j++) { - if (linked_shader->info.TransformFeedback.BufferStride[j]) { - prog->TransformFeedback.BufferStride[j] = - linked_shader->info.TransformFeedback.BufferStride[j]; - - /* We will validate doubles at a later stage */ - if (prog->TransformFeedback.BufferStride[j] % 4) { - linker_error(prog, "invalid qualifier xfb_stride=%d must be a " - "multiple of 4 or if its applied to a type that is " - "or contains a double a multiple of 8.", - prog->TransformFeedback.BufferStride[j]); - return; - } - - if (prog->TransformFeedback.BufferStride[j] / 4 > - ctx->Const.MaxTransformFeedbackInterleavedComponents) { - linker_error(prog, - "The MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS " - "limit has been exceeded."); - return; } } } |