return inst;
}
+static struct brw_sampler_prog_key_data *
+get_tex(gl_shader_stage stage, const void *key)
+{
+ switch (stage) {
+ case MESA_SHADER_FRAGMENT:
+ return &((brw_wm_prog_key*) key)->tex;
+ default:
+ unreachable("unhandled shader stage");
+ }
+}
+
fs_reg
fs_visitor::rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
bool is_rect, uint32_t sampler, int texunit)
fs_inst *inst = NULL;
bool needs_gl_clamp = true;
fs_reg scale_x, scale_y;
- const struct brw_sampler_prog_key_data *tex =
- (stage == MESA_SHADER_FRAGMENT) ?
- &((brw_wm_prog_key*) this->key)->tex : NULL;
- assert(tex);
+ struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key);
/* The 965 requires the EU to do the normalization of GL rectangle
* texture coordinates. We use the program parameter state
uint32_t sampler,
fs_reg sampler_reg, int texunit)
{
- const struct brw_sampler_prog_key_data *tex =
- (stage == MESA_SHADER_FRAGMENT) ?
- &((brw_wm_prog_key*) this->key)->tex : NULL;
- assert(tex);
+ struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key);
fs_inst *inst = NULL;
if (op == ir_tg4) {
void
fs_visitor::visit(ir_texture *ir)
{
- const struct brw_sampler_prog_key_data *tex =
- (stage == MESA_SHADER_FRAGMENT) ?
- &((brw_wm_prog_key*) this->key)->tex : NULL;
- assert(tex);
-
+ const struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key);
uint32_t sampler =
_mesa_get_sampler_uniform_value(ir->sampler, shader_prog, prog);
uint32_t
fs_visitor::gather_channel(int orig_chan, uint32_t sampler)
{
- const struct brw_sampler_prog_key_data *tex =
- (stage == MESA_SHADER_FRAGMENT) ?
- &((brw_wm_prog_key*) this->key)->tex : NULL;
- assert(tex);
+ struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key);
int swiz = GET_SWZ(tex->swizzles[sampler], orig_chan);
switch (swiz) {
case SWIZZLE_X: return 0;
if (op == ir_txs || op == ir_lod || op == ir_tg4)
return;
- const struct brw_sampler_prog_key_data *tex =
- (stage == MESA_SHADER_FRAGMENT) ?
- &((brw_wm_prog_key*) this->key)->tex : NULL;
- assert(tex);
+ struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key);
if (dest_components == 1) {
/* Ignore DEPTH_TEXTURE_MODE swizzling. */