summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2014-08-15 10:17:26 -0700
committerJason Ekstrand <[email protected]>2015-01-15 07:18:58 -0800
commit9afc566e2db974daf097b5816adc26f8d633b080 (patch)
tree7d35c3534c32a22189520de490ea8953de72e2e3 /src
parent616a48ebc6b858cf15ade15238f1a549b701ebc3 (diff)
i965/fs: Don't pass through the coordinate type
All we really need is the number of components.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.h4
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_fp.cpp12
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp27
3 files changed, 21 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index d488c621566..d8ae31e7e86 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -484,7 +484,7 @@ public:
void emit_interpolation_setup_gen4();
void emit_interpolation_setup_gen6();
void compute_sample_position(fs_reg dst, fs_reg int_sample_pos);
- fs_reg rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
+ fs_reg rescale_texcoord(fs_reg coordinate, int coord_components,
bool is_rect, uint32_t sampler, int texunit);
fs_inst *emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
fs_reg coordinate, int coord_components,
@@ -505,7 +505,7 @@ public:
fs_reg offset_value);
void emit_texture(ir_texture_opcode op,
const glsl_type *dest_type,
- fs_reg coordinate, const struct glsl_type *coord_type,
+ fs_reg coordinate, int components,
fs_reg shadow_c,
fs_reg lod, fs_reg dpdy, int grad_components,
fs_reg sample_index,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index 8041740784e..65ce6cf8b0d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -421,26 +421,26 @@ fs_visitor::emit_fragment_program_code()
unreachable("not reached");
}
- const glsl_type *coordinate_type;
+ int coord_components;
switch (fpi->TexSrcTarget) {
case TEXTURE_1D_INDEX:
- coordinate_type = glsl_type::float_type;
+ coord_components = 1;
break;
case TEXTURE_2D_INDEX:
case TEXTURE_1D_ARRAY_INDEX:
case TEXTURE_RECT_INDEX:
case TEXTURE_EXTERNAL_INDEX:
- coordinate_type = glsl_type::vec2_type;
+ coord_components = 2;
break;
case TEXTURE_3D_INDEX:
case TEXTURE_2D_ARRAY_INDEX:
- coordinate_type = glsl_type::vec3_type;
+ coord_components = 3;
break;
case TEXTURE_CUBE_INDEX: {
- coordinate_type = glsl_type::vec3_type;
+ coord_components = 4;
fs_reg temp = fs_reg(this, glsl_type::float_type);
fs_reg cubecoord = fs_reg(this, glsl_type::vec3_type);
@@ -468,7 +468,7 @@ fs_visitor::emit_fragment_program_code()
if (fpi->TexShadow)
shadow_c = offset(coordinate, 2);
- emit_texture(op, glsl_type::vec4_type, coordinate, coordinate_type,
+ emit_texture(op, glsl_type::vec4_type, coordinate, coord_components,
shadow_c, lod, dpdy, 0, sample_index,
reg_undef, 0, /* offset, components */
reg_undef, /* mcs */
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 9c6b197a923..a46173fbc2e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1839,7 +1839,7 @@ get_tex(gl_shader_stage stage, const void *key)
}
fs_reg
-fs_visitor::rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
+fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
bool is_rect, uint32_t sampler, int texunit)
{
fs_inst *inst = NULL;
@@ -1898,7 +1898,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
* tracking to get the scaling factor.
*/
if (brw->gen < 6 && is_rect) {
- fs_reg dst = fs_reg(this, coord_type);
+ fs_reg dst = fs_reg(GRF, virtual_grf_alloc(coord_components));
fs_reg src = coordinate;
coordinate = dst;
@@ -1938,8 +1938,8 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
}
}
- if (coord_type && needs_gl_clamp) {
- for (unsigned int i = 0; i < MIN2(coord_type->vector_elements, 3); i++) {
+ if (coord_components > 0 && needs_gl_clamp) {
+ for (int i = 0; i < MIN2(coord_components, 3); i++) {
if (tex->gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
chan = offset(chan, i);
@@ -1986,7 +1986,7 @@ fs_visitor::emit_mcs_fetch(fs_reg coordinate, int components, fs_reg sampler)
void
fs_visitor::emit_texture(ir_texture_opcode op,
const glsl_type *dest_type,
- fs_reg coordinate, const struct glsl_type *coord_type,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_c,
fs_reg lod, fs_reg lod2, int grad_components,
fs_reg sample_index,
@@ -2023,7 +2023,7 @@ fs_visitor::emit_texture(ir_texture_opcode op,
/* FINISHME: Texture coordinate rescaling doesn't work with non-constant
* samplers. This should only be a problem with GL_CLAMP on Gen7.
*/
- coordinate = rescale_texcoord(coordinate, coord_type, is_rect,
+ coordinate = rescale_texcoord(coordinate, coord_components, is_rect,
sampler, texunit);
}
@@ -2032,8 +2032,6 @@ fs_visitor::emit_texture(ir_texture_opcode op,
*/
fs_reg dst(this, glsl_type::get_instance(dest_type->base_type, 4, 1));
- int coord_components = coord_type ? coord_type->vector_elements : 0;
-
if (brw->gen >= 7) {
inst = emit_texture_gen7(op, dst, coordinate, coord_components,
shadow_c, lod, lod2, grad_components,
@@ -2144,9 +2142,9 @@ fs_visitor::visit(ir_texture *ir)
* generating these values may involve SEND messages that need the MRFs.
*/
fs_reg coordinate;
- const glsl_type *coord_type = NULL;
+ int coord_components = 0;
if (ir->coordinate) {
- coord_type = ir->coordinate->type;
+ coord_components = ir->coordinate->type->vector_elements;
ir->coordinate->accept(this);
coordinate = this->result;
}
@@ -2228,10 +2226,11 @@ fs_visitor::visit(ir_texture *ir)
ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&
ir->sampler->type->sampler_array;
- emit_texture(ir->op, ir->type, coordinate, coord_type, shadow_comparitor,
- lod, lod2, grad_components, sample_index, offset_value,
- offset_components, mcs, gather_component,
- is_cube_array, is_rect, sampler, sampler_reg, texunit);
+ emit_texture(ir->op, ir->type, coordinate, coord_components,
+ shadow_comparitor, lod, lod2, grad_components,
+ sample_index, offset_value, offset_components, mcs,
+ gather_component, is_cube_array, is_rect, sampler,
+ sampler_reg, texunit);
}
/**