aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-23 08:33:10 +0100
committermarha <marha@users.sourceforge.net>2012-01-23 08:33:10 +0100
commit45e3694d529b052f4122262c9bdff5476219b2b4 (patch)
tree173df8f3cea2330e782626e382a90668950d3e6f /mesalib/src/glsl
parenta8ef69cc0c9e5281e6b745dd4a2be75f629eb8b8 (diff)
downloadvcxsrv-45e3694d529b052f4122262c9bdff5476219b2b4.tar.gz
vcxsrv-45e3694d529b052f4122262c9bdff5476219b2b4.tar.bz2
vcxsrv-45e3694d529b052f4122262c9bdff5476219b2b4.zip
git update libX11 mesa libxcb xkeyboard-config 23 jan 2012
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/glsl_types.cpp4
-rw-r--r--mesalib/src/glsl/linker.cpp64
2 files changed, 42 insertions, 26 deletions
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index d4385a644..1489aae6d 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -147,12 +147,12 @@ glsl_type::sampler_index() const
return TEXTURE_RECT_INDEX;
case GLSL_SAMPLER_DIM_BUF:
assert(!"FINISHME: Implement ARB_texture_buffer_object");
- break;
+ return TEXTURE_BUFFER_INDEX;
case GLSL_SAMPLER_DIM_EXTERNAL:
return TEXTURE_EXTERNAL_INDEX;
default:
assert(!"Should not get here.");
- break;
+ return TEXTURE_BUFFER_INDEX;
}
}
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index adedfe6f3..509575192 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1388,9 +1388,10 @@ public:
static bool is_same(const tfeedback_decl &x, const tfeedback_decl &y);
bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog,
ir_variable *output_var);
+ bool accumulate_num_outputs(struct gl_shader_program *prog, unsigned *count);
bool store(struct gl_context *ctx, struct gl_shader_program *prog,
struct gl_transform_feedback_info *info, unsigned buffer,
- unsigned varying) const;
+ unsigned varying, const unsigned max_outputs) const;
/**
@@ -1624,16 +1625,9 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
}
-/**
- * Update gl_transform_feedback_info to reflect this tfeedback_decl.
- *
- * If an error occurs, the error is reported through linker_error() and false
- * is returned.
- */
bool
-tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
- struct gl_transform_feedback_info *info,
- unsigned buffer, unsigned varying) const
+tfeedback_decl::accumulate_num_outputs(struct gl_shader_program *prog,
+ unsigned *count)
{
if (!this->is_assigned()) {
/* From GL_EXT_transform_feedback:
@@ -1648,6 +1642,28 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
return false;
}
+ unsigned translated_size = this->size;
+ if (this->is_clip_distance_mesa)
+ translated_size = (translated_size + 3) / 4;
+
+ *count += translated_size * this->matrix_columns;
+
+ return true;
+}
+
+
+/**
+ * Update gl_transform_feedback_info to reflect this tfeedback_decl.
+ *
+ * If an error occurs, the error is reported through linker_error() and false
+ * is returned.
+ */
+bool
+tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
+ struct gl_transform_feedback_info *info,
+ unsigned buffer,
+ unsigned varying, const unsigned max_outputs) const
+{
/* From GL_EXT_transform_feedback:
* A program will fail to link if:
*
@@ -1663,19 +1679,6 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
return false;
}
- /* Verify that the checks on MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
- * and MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS are sufficient to prevent
- * overflow of info->Outputs[]. In worst case we generate one entry in
- * Outputs[] per component so a conservative check is to verify that the
- * size of the array is greater than or equal to both
- * MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS and
- * MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS.
- */
- assert(Elements(info->Outputs) >=
- ctx->Const.MaxTransformFeedbackInterleavedComponents);
- assert(Elements(info->Outputs) >=
- ctx->Const.MaxTransformFeedbackSeparateComponents);
-
unsigned translated_size = this->size;
if (this->is_clip_distance_mesa)
translated_size = (translated_size + 3) / 4;
@@ -1683,6 +1686,7 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
for (unsigned index = 0; index < translated_size; ++index) {
for (unsigned v = 0; v < this->matrix_columns; ++v) {
unsigned num_components = this->vector_elements;
+ assert(info->NumOutputs < max_outputs);
info->Outputs[info->NumOutputs].ComponentOffset = 0;
if (this->is_clip_distance_mesa) {
if (this->is_subscripted) {
@@ -1976,6 +1980,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS;
ralloc_free(prog->LinkedTransformFeedback.Varyings);
+ ralloc_free(prog->LinkedTransformFeedback.Outputs);
memset(&prog->LinkedTransformFeedback, 0,
sizeof(prog->LinkedTransformFeedback));
@@ -1988,12 +1993,23 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
struct gl_transform_feedback_varying_info,
num_tfeedback_decls);
+ unsigned num_outputs = 0;
+ for (unsigned i = 0; i < num_tfeedback_decls; ++i)
+ if (!tfeedback_decls[i].accumulate_num_outputs(prog, &num_outputs))
+ return false;
+
+ prog->LinkedTransformFeedback.Outputs =
+ rzalloc_array(prog,
+ struct gl_transform_feedback_output,
+ num_outputs);
+
for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
unsigned buffer = separate_attribs_mode ? i : 0;
if (!tfeedback_decls[i].store(ctx, prog, &prog->LinkedTransformFeedback,
- buffer, i))
+ buffer, i, num_outputs))
return false;
}
+ assert(prog->LinkedTransformFeedback.NumOutputs == num_outputs);
return true;
}