This field allows to address output variables more precisely (varyings won't have to "hold" a whole register if they are not vec4). --- src/gallium/state_trackers/dri/drm/dri2.c | 3 +++ src/glsl/ir.cpp | 1 + src/glsl/ir.h | 22 ++++++++++++++++++++++ src/glsl/ir_clone.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs.cpp | 4 ++-- 5 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index afd91ee..4c08a02 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -316,6 +316,9 @@ dri2_allocate_buffer(__DRIscreen *sPriv, switch (format) { case 32: + pf = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 24: pf = PIPE_FORMAT_B8G8R8X8_UNORM; break; case 16: diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index a5eca5a..a4c93ce 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1335,6 +1335,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->pixel_center_integer = false; this->depth_layout = ir_depth_layout_none; this->used = false; + this->horizontal_location = 0; if (type && type->base_type == GLSL_TYPE_SAMPLER) this->read_only = true; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 1faae3c..cf0e444 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -396,6 +396,28 @@ public: * slot has not been assigned, the value will be -1. */ int location; + + /** + * Storage starting component for this variable + * + * Variable storage can be 4-bytes aligned instead of 16-bytes aligned to + * preserve space, for instance a vec2 can be stored in FILE[location].yz + * and in this case, its starting_component is y (eq to 1). + * + * Register can be seen as a 2D array as follow : + * - Locations are assigned to rows, + * - Components are assigned to columns. + * + * 0: [ 0.x 0.y 0.z 0.w] + * 1: [ 1.x 1.y 1.z 1.w] + * 2: [ 2.x 2.y 2.z 2.w] + * ... + * n: [ n.x n.y n.z n.w] + * + * Thus we refers this as "horizontal_location" (vertical location is + * the above "location" field). + */ + unsigned horizontal_location:2; /** * Built-in state that backs this uniform diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index c63615c..17e800a 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -46,6 +46,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->invariant = this->invariant; var->interpolation = this->interpolation; var->location = this->location; + var->horizontal_location = this->horizontal_location; var->warn_extension = this->warn_extension; var->origin_upper_left = this->origin_upper_left; var->pixel_center_integer = this->pixel_center_integer; diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 6ecaa6c..d095e86 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -462,7 +462,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) * field of the setup reg. */ for (unsigned int k = 0; k < type->vector_elements; k++) { - struct brw_reg interp = interp_reg(location, k); + struct brw_reg interp = interp_reg(location, k + ir->horizontal_location); interp = suboffset(interp, 3); interp.type = reg->type; emit(FS_OPCODE_CINTERP, attr, fs_reg(interp)); @@ -482,7 +482,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) k == 3 && !(c->key.proj_attrib_mask & (1 << location))) { emit(BRW_OPCODE_MOV, attr, fs_reg(1.0f)); } else { - struct brw_reg interp = interp_reg(location, k); + struct brw_reg interp = interp_reg(location, k + ir->horizontal_location); brw_wm_barycentric_interp_mode barycoord_mode; if (interpolation_mode == INTERP_QUALIFIER_SMOOTH) barycoord_mode = BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC; -- 1.7.7 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev