summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_context.h
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-10-25 12:52:29 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-10-27 13:54:35 -0700
commit9e3641bd0d739a87a6998300ca29580cb557f380 (patch)
treefc011e451a25a7d3f04850f90e5b5d712052f95e /src/mesa/drivers/dri/i965/brw_context.h
parent502943049af6e8927e2b342365733fabda3d5b88 (diff)
i965: Make FS uniforms be the actual type of the uniform at upload time.
This fixes some insanity that would otherwise be required for GLSL 1.30 bit ops or gen6 integer uniform operations in general, at the cost of upload-time pain. Given that we only have that pain because mesa's mangling our integer uniforms to be floats, this something that should be fixed outside of the shader codegen.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_context.h')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 4a0709b446..335339515a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -188,6 +188,13 @@ struct brw_shader_program {
struct gl_shader_program base;
};
+enum param_conversion {
+ PARAM_NO_CONVERT,
+ PARAM_CONVERT_F2I,
+ PARAM_CONVERT_F2U,
+ PARAM_CONVERT_F2B,
+};
+
/* Data about a particular attempt to compile a program. Note that
* there can be many of these, each in a different GL state
* corresponding to a different brw_wm_prog_key struct, with different
@@ -208,8 +215,10 @@ struct brw_wm_prog_data {
/* Pointer to tracked values (only valid once
* _mesa_load_state_parameters has been called at runtime).
*/
- const GLfloat *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
- const GLfloat *pull_param[MAX_UNIFORMS * 4];
+ const float *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
+ enum param_conversion param_convert[MAX_UNIFORMS * 4];
+ const float *pull_param[MAX_UNIFORMS * 4];
+ enum param_conversion pull_param_convert[MAX_UNIFORMS * 4];
};
struct brw_sf_prog_data {
@@ -800,6 +809,35 @@ brw_fragment_program_const(const struct gl_fragment_program *p)
return (const struct brw_fragment_program *) p;
}
+static inline
+float convert_param(enum param_conversion conversion, float param)
+{
+ union {
+ float f;
+ uint32_t u;
+ int32_t i;
+ } fi;
+
+ switch (conversion) {
+ case PARAM_NO_CONVERT:
+ return param;
+ case PARAM_CONVERT_F2I:
+ fi.i = param;
+ return fi.f;
+ case PARAM_CONVERT_F2U:
+ fi.u = param;
+ return fi.f;
+ case PARAM_CONVERT_F2B:
+ if (param != 0.0)
+ fi.i = 1;
+ else
+ fi.i = 0;
+ return fi.f;
+ default:
+ return param;
+ }
+}
+
GLboolean brw_do_cubemap_normalize(struct exec_list *instructions);
#endif