summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-03-05 10:50:14 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-03-05 10:56:49 +0100
commit4528287e040415c2071012d02f20979ff995c754 (patch)
tree9fbbd0d785c4e9a45ff7c53a8254312bd5ff7bb6 /src/gallium/auxiliary
parentb1922de9f3478869c6788ef4e954c06c20e7aa9c (diff)
gallium: michel's patch to rework texture/sampler binding interface
Bind all the samplers/textures at once rather than piecemeal. This is easier for drivers to understand.
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_aaline.c54
-rw-r--r--src/gallium/auxiliary/draw/draw_pstipple.c51
2 files changed, 56 insertions, 49 deletions
diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c
index 7660e56fe6..3ec73b0800 100644
--- a/src/gallium/auxiliary/draw/draw_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_aaline.c
@@ -78,7 +78,8 @@ struct aaline_stage
void *sampler_cso;
struct pipe_texture *texture;
- uint sampler_unit;
+ uint num_samplers;
+ uint num_textures;
/*
@@ -98,11 +99,10 @@ struct aaline_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
- void (*driver_bind_sampler_state)(struct pipe_context *, unsigned, void *);
-
- void (*driver_set_sampler_texture)(struct pipe_context *,
- unsigned sampler,
- struct pipe_texture *);
+ void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
+ void **);
+ void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
+ struct pipe_texture **);
struct pipe_context *pipe;
};
@@ -607,6 +607,7 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
auto struct aaline_stage *aaline = aaline_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = aaline->pipe;
+ uint num = MAX2(aaline->num_textures, aaline->num_samplers);
assert(draw->rasterizer->line_smooth);
@@ -624,8 +625,11 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
*/
bind_aaline_fragment_shader(aaline);
- aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit, aaline->sampler_cso);
- aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit, aaline->texture);
+ aaline->state.sampler[num] = aaline->sampler_cso;
+ aaline->state.texture[num] = aaline->texture;
+
+ aaline->driver_bind_sampler_states(pipe, num + 1, aaline->state.sampler);
+ aaline->driver_set_sampler_textures(pipe, num + 1, aaline->state.texture);
/* now really draw first line */
stage->line = aaline_line;
@@ -647,10 +651,10 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
/* XXX restore original texture, sampler state */
- aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit,
- aaline->state.sampler[aaline->sampler_unit]);
- aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit,
- aaline->state.texture[aaline->sampler_unit]);
+ aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
+ aaline->state.sampler);
+ aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
+ aaline->state.texture);
draw->extra_vp_outputs.slot = 0;
}
@@ -745,26 +749,28 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
static void
-aaline_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+aaline_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */
- aaline->state.sampler[unit] = sampler;
+ memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
+ aaline->num_samplers = num;
/* pass-through */
- aaline->driver_bind_sampler_state(aaline->pipe, unit, sampler);
+ aaline->driver_bind_sampler_states(aaline->pipe, num, sampler);
}
static void
-aaline_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler, struct pipe_texture *texture)
+aaline_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num, struct pipe_texture **texture)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */
- aaline->state.texture[sampler] = texture;
+ memcpy(aaline->state.texture, texture, num * sizeof(struct pipe_texture *));
+ aaline->num_textures = num;
/* pass-through */
- aaline->driver_set_sampler_texture(aaline->pipe, sampler, texture);
+ aaline->driver_set_sampler_textures(aaline->pipe, num, texture);
}
@@ -798,14 +804,14 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
aaline->driver_bind_fs_state = pipe->bind_fs_state;
aaline->driver_delete_fs_state = pipe->delete_fs_state;
- aaline->driver_bind_sampler_state = pipe->bind_sampler_state;
- aaline->driver_set_sampler_texture = pipe->set_sampler_texture;
+ aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
+ aaline->driver_set_sampler_textures = pipe->set_sampler_textures;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
pipe->bind_fs_state = aaline_bind_fs_state;
pipe->delete_fs_state = aaline_delete_fs_state;
- pipe->bind_sampler_state = aaline_bind_sampler_state;
- pipe->set_sampler_texture = aaline_set_sampler_texture;
+ pipe->bind_sampler_states = aaline_bind_sampler_states;
+ pipe->set_sampler_textures = aaline_set_sampler_textures;
}
diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c
index 2cfeb813b3..894b136f2c 100644
--- a/src/gallium/auxiliary/draw/draw_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pstipple.c
@@ -68,7 +68,8 @@ struct pstip_stage
void *sampler_cso;
struct pipe_texture *texture;
- uint sampler_unit;
+ uint num_samplers;
+ uint num_textures;
/*
* Currently bound state
@@ -88,11 +89,10 @@ struct pstip_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
- void (*driver_bind_sampler_state)(struct pipe_context *, unsigned, void *);
+ void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, void **);
- void (*driver_set_sampler_texture)(struct pipe_context *,
- unsigned sampler,
- struct pipe_texture *);
+ void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
+ struct pipe_texture **);
void (*driver_set_polygon_stipple)(struct pipe_context *,
const struct pipe_poly_stipple *);
@@ -328,8 +328,6 @@ generate_pstip_fs(struct pstip_stage *pstip)
tgsi_dump(pstip_fs.tokens, 0);
#endif
- pstip->sampler_unit = transform.maxSampler + 1;
-
#if 1 /* XXX remove */
if (transform.wincoordInput < 0) {
pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION;
@@ -486,6 +484,7 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
struct pstip_stage *pstip = pstip_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = pstip->pipe;
+ uint num = MAX2(pstip->num_textures, pstip->num_samplers);
assert(draw->rasterizer->poly_stipple_enable);
@@ -494,8 +493,8 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
*/
bind_pstip_fragment_shader(pstip);
- pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit, pstip->sampler_cso);
- pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit, pstip->texture);
+ pstip->driver_bind_sampler_states(pipe, num + 1, pstip->state.sampler);
+ pstip->driver_set_sampler_textures(pipe, num + 1, pstip->state.texture);
/* now really draw first line */
stage->tri = passthrough_tri;
@@ -517,10 +516,10 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
/* XXX restore original texture, sampler state */
- pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit,
- pstip->state.sampler[pstip->sampler_unit]);
- pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit,
- pstip->state.texture[pstip->sampler_unit]);
+ pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
+ pstip->state.sampler);
+ pstip->driver_set_sampler_textures(pipe, pstip->num_textures,
+ pstip->state.texture);
}
@@ -613,26 +612,28 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
static void
-pstip_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+pstip_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */
- pstip->state.sampler[unit] = sampler;
+ memcpy(pstip->state.sampler, sampler, num * sizeof(void *));
+ pstip->num_samplers = num;
/* pass-through */
- pstip->driver_bind_sampler_state(pstip->pipe, unit, sampler);
+ pstip->driver_bind_sampler_states(pstip->pipe, num, sampler);
}
static void
-pstip_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler, struct pipe_texture *texture)
+pstip_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num, struct pipe_texture **texture)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */
- pstip->state.texture[sampler] = texture;
+ memcpy(pstip->state.texture, texture, num * sizeof(struct pipe_texture *));
+ pstip->num_textures = num;
/* pass-through */
- pstip->driver_set_sampler_texture(pstip->pipe, sampler, texture);
+ pstip->driver_set_sampler_textures(pstip->pipe, num, texture);
}
@@ -682,8 +683,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
pstip->driver_bind_fs_state = pipe->bind_fs_state;
pstip->driver_delete_fs_state = pipe->delete_fs_state;
- pstip->driver_bind_sampler_state = pipe->bind_sampler_state;
- pstip->driver_set_sampler_texture = pipe->set_sampler_texture;
+ pstip->driver_bind_sampler_states = pipe->bind_sampler_states;
+ pstip->driver_set_sampler_textures = pipe->set_sampler_textures;
pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
/* override the driver's functions */
@@ -691,7 +692,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
pipe->bind_fs_state = pstip_bind_fs_state;
pipe->delete_fs_state = pstip_delete_fs_state;
- pipe->bind_sampler_state = pstip_bind_sampler_state;
- pipe->set_sampler_texture = pstip_set_sampler_texture;
+ pipe->bind_sampler_states = pstip_bind_sampler_states;
+ pipe->set_sampler_textures = pstip_set_sampler_textures;
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
}