cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
cell->pipe.set_polygon_stipple = cell_set_polygon_stipple;
- cell->pipe.set_sampler_units = cell_set_sampler_units;
cell->pipe.set_scissor_state = cell_set_scissor_state;
cell->pipe.set_texture_state = cell_set_texture_state;
cell->pipe.set_viewport_state = cell_set_viewport_state;
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
- uint sampler_units[PIPE_MAX_SAMPLERS];
uint dirty;
/** The primitive drawing context */
void cell_set_polygon_stipple( struct pipe_context *,
const struct pipe_poly_stipple * );
-void cell_set_sampler_units( struct pipe_context *,
- uint numSamplers, const uint *units );
-
void cell_set_scissor_state( struct pipe_context *,
const struct pipe_scissor_state * );
void
-cell_set_texture_state(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
+cell_set_sampler_texture(struct pipe_context *pipe,
+ unsigned sampler,
+ struct pipe_texture *texture)
{
struct cell_context *cell = cell_context(pipe);
assert(unit < PIPE_MAX_SAMPLERS);
#if 0
- cell->texture[unit] = cell_texture(texture); /* ptr, not struct */
- cell_tile_cache_set_texture(cell->tex_cache[unit], texture);
+ cell->texture[sampler] = cell_texture(texture); /* ptr, not struct */
+ cell_tile_cache_set_texture(cell->tex_cache[sampler], texture);
#endif
cell->dirty |= CELL_NEW_TEXTURE;
}
-void
-cell_set_sampler_units(struct pipe_context *pipe,
- uint num_samplers, const uint *units )
-{
- struct cell_context *cell = cell_context(pipe);
- uint i;
- for (i = 0; i < num_samplers; i++)
- cell->sampler_units[i] = units[i];
- cell->dirty |= CELL_NEW_SAMPLER;
-}
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- uint sampler_units[PIPE_MAX_SAMPLERS];
struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
failover->hw->set_polygon_stipple( failover->hw, stipple );
}
-static void
-failover_set_sampler_units( struct pipe_context *pipe,
- uint num_samplers, const uint *units )
-{
- struct failover_context *failover = failover_context(pipe);
- uint i;
-
- for (i = 0; i < num_samplers; i++)
- failover->sampler_units[i] = units[i];
- failover->dirty |= FO_NEW_SAMPLER;
- failover->hw->set_sampler_units(failover->hw, num_samplers, units);
-}
static void *
failover_create_rasterizer_state(struct pipe_context *pipe,
static void
-failover_set_texture_state(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
+failover_set_sampler_texture(struct pipe_context *pipe,
+ unsigned unit,
+ struct pipe_texture *texture)
{
struct failover_context *failover = failover_context(pipe);
failover->texture[unit] = texture;
failover->dirty |= FO_NEW_TEXTURE;
failover->dirty_texture |= (1<<unit);
- failover->hw->set_texture_state( failover->hw, unit, texture );
+ failover->hw->set_sampler_texture( failover->hw, unit, texture );
}
failover->pipe.set_clip_state = failover_set_clip_state;
failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
- failover->pipe.set_sampler_units = failover_set_sampler_units;
failover->pipe.set_scissor_state = failover_set_scissor_state;
- failover->pipe.set_texture_state = failover_set_texture_state;
+ failover->pipe.set_sampler_texture = failover_set_sampler_texture;
failover->pipe.set_viewport_state = failover_set_viewport_state;
failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
failover->pipe.set_vertex_element = failover_set_vertex_element;
if (failover->dirty & FO_NEW_TEXTURE) {
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
if (failover->dirty_texture & (1<<i)) {
- failover->sw->set_texture_state( failover->sw, i,
+ failover->sw->set_sampler_texture( failover->sw, i,
failover->texture[i] );
}
}
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- uint sampler_units[PIPE_MAX_SAMPLERS];
struct i915_texture *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
{
}
-static void i915_set_sampler_units(struct pipe_context *pipe,
- uint numSamplers, const uint *units)
-{
- struct i915_context *i915 = i915_context(pipe);
- uint i;
- for (i = 0; i < numSamplers; i++)
- i915->sampler_units[i] = units[i];
-}
static void * i915_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
}
-static void i915_set_texture_state(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
+static void i915_set_sampler_texture(struct pipe_context *pipe,
+ unsigned sampler,
+ struct pipe_texture *texture)
{
struct i915_context *i915 = i915_context(pipe);
- i915->texture[unit] = (struct i915_texture*)texture; /* ptr, not struct */
+ i915->texture[sampler] = (struct i915_texture*)texture; /* ptr, not struct */
i915->dirty |= I915_NEW_TEXTURE;
}
i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
- i915->pipe.set_sampler_units = i915_set_sampler_units;
i915->pipe.set_scissor_state = i915_set_scissor_state;
- i915->pipe.set_texture_state = i915_set_texture_state;
+ i915->pipe.set_sampler_texture = i915_set_sampler_texture;
i915->pipe.set_viewport_state = i915_set_viewport_state;
i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
i915->pipe.set_vertex_element = i915_set_vertex_element;
}
-static void brw_set_sampler_units(struct pipe_context *pipe,
- uint numSamplers, const uint *units)
-{
-}
-
/************************************************************************
* Depth stencil
*/
*/
-static void brw_set_texture_state(struct pipe_context *pipe,
+static void brw_set_sampler_texture(struct pipe_context *pipe,
unsigned unit,
struct pipe_texture *texture)
{
// brw->pipe.set_feedback_buffer = brw_set_feedback_buffer;
brw->pipe.set_polygon_stipple = brw_set_polygon_stipple;
- brw->pipe.set_sampler_units = brw_set_sampler_units;
brw->pipe.set_scissor_state = brw_set_scissor_state;
- brw->pipe.set_texture_state = brw_set_texture_state;
+ brw->pipe.set_sampler_texture = brw_set_sampler_texture;
brw->pipe.set_viewport_state = brw_set_viewport_state;
brw->pipe.set_vertex_buffer = brw_set_vertex_buffer;
brw->pipe.set_vertex_element = brw_set_vertex_element;
float (*inputs)[16][4],
int num_attribs,
float (*consts)[4], int num_consts,
- struct tgsi_sampler *samplers,
- unsigned *sampler_units);
+ struct tgsi_sampler *samplers);
int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
float fx, float fy,
float (*dests)[16][4],
float (*inputs)[16][4],
float (*consts)[4],
- struct tgsi_sampler *samplers,
- unsigned *sampler_units)
+ struct tgsi_sampler *samplers)
{
fragment_shader_runner runner = reinterpret_cast<fragment_shader_runner>(prog->function);
assert(runner);
runner(fx, fy, dests, inputs, prog->num_interp,
consts, prog->num_consts,
- samplers, sampler_units);
+ samplers);
return 0;
}
float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
float (*consts)[4],
- struct tgsi_sampler *samplers,
- unsigned *sampler_units);
+ struct tgsi_sampler *samplers);
void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
const struct tgsi_interp_coef *coefs);
int32_num_consts_125->setName("num_consts");
Value* ptr_samplers = args++;
ptr_samplers->setName("samplers");
- Value* ptr_sampler_units = args++;
- ptr_sampler_units->setName("sampler_units");
BasicBlock* label_entry_126 = new BasicBlock("entry",func_run_fragment_shader,0);
BasicBlock* label_forbody6_i_127 = new BasicBlock("forbody6.i",func_run_fragment_shader,0);
int num_inputs,
float (*aconsts)[4],
int num_consts,
- struct tgsi_sampler *samplers,
- unsigned *sampler_units)
+ struct tgsi_sampler *samplers)
{
float4 inputs[4][16];
float4 consts[32];
void (*set_polygon_stipple)( struct pipe_context *,
const struct pipe_poly_stipple * );
- void (*set_sampler_units)( struct pipe_context *,
- uint num_samplers, const uint *units );
-
void (*set_scissor_state)( struct pipe_context *,
const struct pipe_scissor_state * );
- void (*set_texture_state)( struct pipe_context *,
- unsigned unit,
- struct pipe_texture * );
+
+ /* Currently a sampler is constrained to sample from a single texture:
+ */
+ void (*set_sampler_texture)( struct pipe_context *,
+ unsigned sampler,
+ struct pipe_texture * );
void (*set_viewport_state)( struct pipe_context *,
const struct pipe_viewport_state * );
softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
- softpipe->pipe.set_sampler_units = softpipe_set_sampler_units;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
- softpipe->pipe.set_texture_state = softpipe_set_texture_state;
+ softpipe->pipe.set_sampler_texture = softpipe_set_sampler_texture;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer;
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
- uint sampler_units[PIPE_MAX_SAMPLERS];
unsigned dirty;
/*
/* Consts does not require 16 byte alignment. */
machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT];
- machine->SamplerUnits = softpipe->sampler_units;
machine->InterpCoefs = quad->coef;
machine->Inputs[0].xyzw[0].f[0] = fx;
/*quad->mask &=*/
gallivm_fragment_shader_exec(llvm, fx, fy, dests, inputs,
softpipe->mapped_constants[PIPE_SHADER_FRAGMENT],
- qss->samplers, softpipe->sampler_units);
+ qss->samplers);
#if DLLVM
printf("OUT LLVM = 1[%f %f %f %f], 2[%f %f %f %f]\n",
dests[0][0][0], dests[0][0][1], dests[0][0][2], dests[0][0][3],
void softpipe_set_polygon_stipple( struct pipe_context *,
const struct pipe_poly_stipple * );
-void softpipe_set_sampler_units( struct pipe_context *,
- uint numSamplers, const uint *units );
-
void softpipe_set_scissor_state( struct pipe_context *,
const struct pipe_scissor_state * );
-void softpipe_set_texture_state( struct pipe_context *,
+void softpipe_set_sampler_texture( struct pipe_context *,
unsigned unit,
struct pipe_texture * );
void
-softpipe_set_texture_state(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
+softpipe_set_sampler_texture(struct pipe_context *pipe,
+ unsigned unit,
+ struct pipe_texture *texture)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
}
-void
-softpipe_set_sampler_units(struct pipe_context *pipe,
- uint num_samplers, const uint *units )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- uint i;
- for (i = 0; i < num_samplers; i++)
- softpipe->sampler_units[i] = units[i];
- softpipe->dirty |= SP_NEW_SAMPLER;
-}
-
const struct tgsi_full_instruction *inst,
boolean biasLod)
{
- const uint sampler = inst->FullSrcRegisters[1].SrcRegister.Index;
- const uint unit = mach->SamplerUnits[sampler];
+ const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
union tgsi_exec_channel r[8];
uint chan_index;
float lodBias;
struct tgsi_exec_vector *Temps;
struct tgsi_exec_vector *Addrs;
- uint *SamplerUnits;
struct tgsi_sampler *Samplers;
float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
st->pipe->bind_sampler_state(st->pipe, u, cso->data);
}
}
-
-
- /* mapping from sampler vars to texture units */
- {
- struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
- uint sample_units[PIPE_MAX_SAMPLERS];
- uint s;
- for (s = 0; s < PIPE_MAX_SAMPLERS; s++) {
- sample_units[s] = fprog->Base.SamplerUnits[s];
- }
-
- st->pipe->set_sampler_units(st->pipe, PIPE_MAX_SAMPLERS, sample_units);
- }
}
const struct st_tracked_state st_update_sampler = {
.name = "st_update_sampler",
.dirty = {
- .mesa = _NEW_TEXTURE | _NEW_PROGRAM,
+ .mesa = _NEW_TEXTURE,
.st = 0,
},
.update = update_samplers
static void
update_textures(struct st_context *st)
{
- GLuint u;
+ GLuint s;
- for (u = 0; u < st->ctx->Const.MaxTextureImageUnits; u++) {
+ /* ST_NEW_FRAGMENT_PROGRAM
+ */
+ struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+
+ for (s = 0; s < st->ctx->Const.MaxTextureCoordUnits; s++) {
+ GLuint su = fprog->Base.SamplerUnits[s];
+
struct gl_texture_object *texObj
- = st->ctx->Texture.Unit[u]._Current;
+ = st->ctx->Texture.Unit[su]._Current;
+
struct pipe_texture *pt;
+
if (texObj) {
GLboolean flush, retval;
- retval = st_finalize_texture(st->ctx, st->pipe, u, &flush);
-#if 0
- printf("finalize_texture returned %d, flush = %d\n",
- retval, flush);
-#endif
+ retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
pt = st_get_texobj_texture(texObj);
}
pt = NULL;
}
- st->state.texture[u] = pt;
- st->pipe->set_texture_state(st->pipe, u, pt);
+ /* XXX: need to ensure that textures are unbound/removed from
+ * this table before being deleted, otherwise the pointer
+ * comparison below could fail.
+ */
+ if (st->state.sampler_texture[s] != pt) {
+ st->state.sampler_texture[s] = pt;
+ st->pipe->set_sampler_texture(st->pipe, s, pt);
+ }
}
}
.name = "st_update_texture",
.dirty = {
.mesa = _NEW_TEXTURE,
- .st = 0,
+ .st = ST_NEW_FRAGMENT_PROGRAM,
},
.update = update_textures
};
/* texture state: */
{
- pipe->set_texture_state(pipe, unit, pt);
+ pipe->set_sampler_texture(pipe, unit, pt);
}
/* Compute window coords (y=0=bottom) with pixel zoom.
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
pipe->bind_vs_state(pipe, ctx->st->state.vs->data);
- pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
+ pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
}
*/
GLboolean
st_finalize_texture(GLcontext *ctx,
- struct pipe_context *pipe, GLuint unit,
+ struct pipe_context *pipe,
+ struct gl_texture_object *tObj,
GLboolean *needFlush)
{
- struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct st_texture_object *stObj = st_texture_object(tObj);
int comp_byte = 0;
int cpp;
extern GLboolean
st_finalize_texture(GLcontext *ctx,
- struct pipe_context *pipe, GLuint unit,
+ struct pipe_context *pipe,
+ struct gl_texture_object *tObj,
GLboolean *needFlush);
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[2];
struct pipe_framebuffer_state framebuffer;
- struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+ struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;