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.
This commit is contained in:
Keith Whitwell
2008-03-05 10:50:14 +01:00
parent b1922de9f3
commit 4528287e04
25 changed files with 2565 additions and 2453 deletions

View File

@@ -78,7 +78,8 @@ struct aaline_stage
void *sampler_cso; void *sampler_cso;
struct pipe_texture *texture; 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_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_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 *, void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
unsigned sampler, struct pipe_texture **);
struct pipe_texture *);
struct pipe_context *pipe; 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); auto struct aaline_stage *aaline = aaline_stage(stage);
struct draw_context *draw = stage->draw; struct draw_context *draw = stage->draw;
struct pipe_context *pipe = aaline->pipe; struct pipe_context *pipe = aaline->pipe;
uint num = MAX2(aaline->num_textures, aaline->num_samplers);
assert(draw->rasterizer->line_smooth); 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); bind_aaline_fragment_shader(aaline);
aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit, aaline->sampler_cso); aaline->state.sampler[num] = aaline->sampler_cso;
aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit, aaline->texture); 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 */ /* now really draw first line */
stage->line = aaline_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); aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
/* XXX restore original texture, sampler state */ /* XXX restore original texture, sampler state */
aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit, aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
aaline->state.sampler[aaline->sampler_unit]); aaline->state.sampler);
aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit, aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
aaline->state.texture[aaline->sampler_unit]); aaline->state.texture);
draw->extra_vp_outputs.slot = 0; draw->extra_vp_outputs.slot = 0;
} }
@@ -745,26 +749,28 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
static void static void
aaline_bind_sampler_state(struct pipe_context *pipe, aaline_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */ /* save current */
aaline->state.sampler[unit] = sampler; memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
aaline->num_samplers = num;
/* pass-through */ /* pass-through */
aaline->driver_bind_sampler_state(aaline->pipe, unit, sampler); aaline->driver_bind_sampler_states(aaline->pipe, num, sampler);
} }
static void static void
aaline_set_sampler_texture(struct pipe_context *pipe, aaline_set_sampler_textures(struct pipe_context *pipe,
unsigned sampler, struct pipe_texture *texture) unsigned num, struct pipe_texture **texture)
{ {
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */ /* save current */
aaline->state.texture[sampler] = texture; memcpy(aaline->state.texture, texture, num * sizeof(struct pipe_texture *));
aaline->num_textures = num;
/* pass-through */ /* 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_bind_fs_state = pipe->bind_fs_state;
aaline->driver_delete_fs_state = pipe->delete_fs_state; aaline->driver_delete_fs_state = pipe->delete_fs_state;
aaline->driver_bind_sampler_state = pipe->bind_sampler_state; aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
aaline->driver_set_sampler_texture = pipe->set_sampler_texture; aaline->driver_set_sampler_textures = pipe->set_sampler_textures;
/* override the driver's functions */ /* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state; pipe->create_fs_state = aaline_create_fs_state;
pipe->bind_fs_state = aaline_bind_fs_state; pipe->bind_fs_state = aaline_bind_fs_state;
pipe->delete_fs_state = aaline_delete_fs_state; pipe->delete_fs_state = aaline_delete_fs_state;
pipe->bind_sampler_state = aaline_bind_sampler_state; pipe->bind_sampler_states = aaline_bind_sampler_states;
pipe->set_sampler_texture = aaline_set_sampler_texture; pipe->set_sampler_textures = aaline_set_sampler_textures;
} }

View File

@@ -68,7 +68,8 @@ struct pstip_stage
void *sampler_cso; void *sampler_cso;
struct pipe_texture *texture; struct pipe_texture *texture;
uint sampler_unit; uint num_samplers;
uint num_textures;
/* /*
* Currently bound state * Currently bound state
@@ -88,11 +89,10 @@ struct pstip_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *); void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_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 *, void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
unsigned sampler, struct pipe_texture **);
struct pipe_texture *);
void (*driver_set_polygon_stipple)(struct pipe_context *, void (*driver_set_polygon_stipple)(struct pipe_context *,
const struct pipe_poly_stipple *); const struct pipe_poly_stipple *);
@@ -328,8 +328,6 @@ generate_pstip_fs(struct pstip_stage *pstip)
tgsi_dump(pstip_fs.tokens, 0); tgsi_dump(pstip_fs.tokens, 0);
#endif #endif
pstip->sampler_unit = transform.maxSampler + 1;
#if 1 /* XXX remove */ #if 1 /* XXX remove */
if (transform.wincoordInput < 0) { if (transform.wincoordInput < 0) {
pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION; 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 pstip_stage *pstip = pstip_stage(stage);
struct draw_context *draw = stage->draw; struct draw_context *draw = stage->draw;
struct pipe_context *pipe = pstip->pipe; struct pipe_context *pipe = pstip->pipe;
uint num = MAX2(pstip->num_textures, pstip->num_samplers);
assert(draw->rasterizer->poly_stipple_enable); 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); bind_pstip_fragment_shader(pstip);
pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit, pstip->sampler_cso); pstip->driver_bind_sampler_states(pipe, num + 1, pstip->state.sampler);
pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit, pstip->texture); pstip->driver_set_sampler_textures(pipe, num + 1, pstip->state.texture);
/* now really draw first line */ /* now really draw first line */
stage->tri = passthrough_tri; 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); pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
/* XXX restore original texture, sampler state */ /* XXX restore original texture, sampler state */
pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit, pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
pstip->state.sampler[pstip->sampler_unit]); pstip->state.sampler);
pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit, pstip->driver_set_sampler_textures(pipe, pstip->num_textures,
pstip->state.texture[pstip->sampler_unit]); pstip->state.texture);
} }
@@ -613,26 +612,28 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
static void static void
pstip_bind_sampler_state(struct pipe_context *pipe, pstip_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe); struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */ /* save current */
pstip->state.sampler[unit] = sampler; memcpy(pstip->state.sampler, sampler, num * sizeof(void *));
pstip->num_samplers = num;
/* pass-through */ /* pass-through */
pstip->driver_bind_sampler_state(pstip->pipe, unit, sampler); pstip->driver_bind_sampler_states(pstip->pipe, num, sampler);
} }
static void static void
pstip_set_sampler_texture(struct pipe_context *pipe, pstip_set_sampler_textures(struct pipe_context *pipe,
unsigned sampler, struct pipe_texture *texture) unsigned num, struct pipe_texture **texture)
{ {
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe); struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */ /* save current */
pstip->state.texture[sampler] = texture; memcpy(pstip->state.texture, texture, num * sizeof(struct pipe_texture *));
pstip->num_textures = num;
/* pass-through */ /* 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_bind_fs_state = pipe->bind_fs_state;
pstip->driver_delete_fs_state = pipe->delete_fs_state; pstip->driver_delete_fs_state = pipe->delete_fs_state;
pstip->driver_bind_sampler_state = pipe->bind_sampler_state; pstip->driver_bind_sampler_states = pipe->bind_sampler_states;
pstip->driver_set_sampler_texture = pipe->set_sampler_texture; pstip->driver_set_sampler_textures = pipe->set_sampler_textures;
pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple; pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
/* override the driver's functions */ /* 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->bind_fs_state = pstip_bind_fs_state;
pipe->delete_fs_state = pstip_delete_fs_state; pipe->delete_fs_state = pstip_delete_fs_state;
pipe->bind_sampler_state = pstip_bind_sampler_state; pipe->bind_sampler_states = pstip_bind_sampler_states;
pipe->set_sampler_texture = pstip_set_sampler_texture; pipe->set_sampler_textures = pstip_set_sampler_textures;
pipe->set_polygon_stipple = pstip_set_polygon_stipple; pipe->set_polygon_stipple = pstip_set_polygon_stipple;
} }

View File

@@ -87,12 +87,15 @@ struct failover_context {
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
void *sw_sampler_state[PIPE_MAX_SAMPLERS];
void *hw_sampler_state[PIPE_MAX_SAMPLERS];
unsigned dirty; unsigned dirty;
unsigned dirty_sampler;
unsigned dirty_texture;
unsigned dirty_vertex_buffer; unsigned dirty_vertex_buffer;
unsigned dirty_vertex_element; unsigned dirty_vertex_element;
unsigned num_samplers;
unsigned num_textures;
unsigned mode; unsigned mode;
struct pipe_context *hw; struct pipe_context *hw;

View File

@@ -28,6 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "pipe/p_inlines.h"
#include "fo_context.h" #include "fo_context.h"
@@ -322,18 +324,27 @@ failover_create_sampler_state(struct pipe_context *pipe,
} }
static void static void
failover_bind_sampler_state(struct pipe_context *pipe, failover_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct failover_context *failover = failover_context(pipe); struct failover_context *failover = failover_context(pipe);
struct fo_state *state = (struct fo_state*)sampler; struct fo_state *state = (struct fo_state*)sampler;
failover->sampler[unit] = state; uint i;
assert(num <= PIPE_MAX_SAMPLERS);
/* Check for no-op */
if (num == failover->num_samplers &&
!memcmp(failover->sampler, sampler, num * sizeof(void *)))
return;
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
failover->sw_sampler_state[i] = i < num ? state[i].sw_state : NULL;
failover->hw_sampler_state[i] = i < num ? state[i].hw_state : NULL;
}
failover->dirty |= FO_NEW_SAMPLER; failover->dirty |= FO_NEW_SAMPLER;
failover->dirty_sampler |= (1<<unit); failover->num_samplers = num;
failover->sw->bind_sampler_state(failover->sw, unit, failover->sw->bind_sampler_states(failover->sw, num,
state->sw_state); failover->sw_sampler_state);
failover->hw->bind_sampler_state(failover->hw, unit, failover->hw->bind_sampler_states(failover->hw, num,
state->hw_state); failover->hw_sampler_state);
} }
static void static void
@@ -351,17 +362,29 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
static void static void
failover_set_sampler_texture(struct pipe_context *pipe, failover_set_sampler_textures(struct pipe_context *pipe,
unsigned unit, unsigned num,
struct pipe_texture *texture) struct pipe_texture **texture)
{ {
struct failover_context *failover = failover_context(pipe); struct failover_context *failover = failover_context(pipe);
uint i;
failover->texture[unit] = texture; assert(num <= PIPE_MAX_SAMPLERS);
/* Check for no-op */
if (num == failover->num_textures &&
!memcmp(failover->texture, texture, num * sizeof(struct pipe_texture *)))
return;
for (i = 0; i < num; i++)
pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
texture[i]);
for (i = num; i < failover->num_textures; i++)
pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
NULL);
failover->dirty |= FO_NEW_TEXTURE; failover->dirty |= FO_NEW_TEXTURE;
failover->dirty_texture |= (1<<unit); failover->num_textures = num;
failover->sw->set_sampler_texture( failover->sw, unit, texture ); failover->sw->set_sampler_textures( failover->sw, num, texture );
failover->hw->set_sampler_texture( failover->hw, unit, texture ); failover->hw->set_sampler_textures( failover->hw, num, texture );
} }
@@ -429,7 +452,7 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.bind_blend_state = failover_bind_blend_state; failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state; failover->pipe.delete_blend_state = failover_delete_blend_state;
failover->pipe.create_sampler_state = failover_create_sampler_state; failover->pipe.create_sampler_state = failover_create_sampler_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.bind_sampler_states = failover_bind_sampler_states;
failover->pipe.delete_sampler_state = failover_delete_sampler_state; failover->pipe.delete_sampler_state = failover_delete_sampler_state;
failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state; failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state; failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state;
@@ -449,7 +472,7 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
failover->pipe.set_scissor_state = failover_set_scissor_state; failover->pipe.set_scissor_state = failover_set_scissor_state;
failover->pipe.set_sampler_texture = failover_set_sampler_texture; failover->pipe.set_sampler_textures = failover_set_sampler_textures;
failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_viewport_state = failover_set_viewport_state;
failover->pipe.set_vertex_buffer = failover_set_vertex_buffer; failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
failover->pipe.set_vertex_element = failover_set_vertex_element; failover->pipe.set_vertex_element = failover_set_vertex_element;

View File

@@ -94,21 +94,13 @@ failover_state_emit( struct failover_context *failover )
failover->sw->set_viewport_state( failover->sw, &failover->viewport ); failover->sw->set_viewport_state( failover->sw, &failover->viewport );
if (failover->dirty & FO_NEW_SAMPLER) { if (failover->dirty & FO_NEW_SAMPLER) {
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { failover->sw->bind_sampler_states( failover->sw, failover->num_samplers,
if (failover->dirty_sampler & (1<<i)) { failover->sw_sampler_state );
failover->sw->bind_sampler_state( failover->sw, i,
failover->sampler[i]->sw_state );
}
}
} }
if (failover->dirty & FO_NEW_TEXTURE) { if (failover->dirty & FO_NEW_TEXTURE) {
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { failover->sw->set_sampler_textures( failover->sw, failover->num_textures,
if (failover->dirty_texture & (1<<i)) { failover->texture );
failover->sw->set_sampler_texture( failover->sw, i,
failover->texture[i] );
}
}
} }
if (failover->dirty & FO_NEW_VERTEX_BUFFER) { if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
@@ -132,6 +124,4 @@ failover_state_emit( struct failover_context *failover )
failover->dirty = 0; failover->dirty = 0;
failover->dirty_vertex_element = 0; failover->dirty_vertex_element = 0;
failover->dirty_vertex_buffer = 0; failover->dirty_vertex_buffer = 0;
failover->dirty_texture = 0;
failover->dirty_sampler = 0;
} }

View File

@@ -236,6 +236,9 @@ struct i915_context
unsigned dirty; unsigned dirty;
unsigned num_samplers;
unsigned num_textures;
unsigned *batch_start; unsigned *batch_start;
/** Vertex buffer */ /** Vertex buffer */

View File

@@ -269,13 +269,22 @@ i915_create_sampler_state(struct pipe_context *pipe,
return cso; return cso;
} }
static void i915_bind_sampler_state(struct pipe_context *pipe, static void i915_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct i915_context *i915 = i915_context(pipe); struct i915_context *i915 = i915_context(pipe);
assert(unit < PIPE_MAX_SAMPLERS); assert(num <= PIPE_MAX_SAMPLERS);
i915->sampler[unit] = (const struct i915_sampler_state*)sampler;
/* Check for no-op */
if (num == i915->num_samplers &&
!memcmp(i915->sampler, sampler, num * sizeof(void *)))
return;
memcpy(i915->sampler, sampler, num * sizeof(void *));
memset(&i915->sampler[num], 0, (PIPE_MAX_SAMPLERS - num) * sizeof(void *));
i915->num_samplers = num;
i915->dirty |= I915_NEW_SAMPLER; i915->dirty |= I915_NEW_SAMPLER;
} }
@@ -526,14 +535,29 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
} }
static void i915_set_sampler_texture(struct pipe_context *pipe, static void i915_set_sampler_textures(struct pipe_context *pipe,
unsigned sampler, unsigned num,
struct pipe_texture *texture) struct pipe_texture **texture)
{ {
struct i915_context *i915 = i915_context(pipe); struct i915_context *i915 = i915_context(pipe);
uint i;
pipe_texture_reference((struct pipe_texture **) &i915->texture[sampler], assert(num <= PIPE_MAX_SAMPLERS);
texture);
/* Check for no-op */
if (num == i915->num_textures &&
!memcmp(i915->texture, texture, num * sizeof(struct pipe_texture *)))
return;
for (i = 0; i < num; i++)
pipe_texture_reference((struct pipe_texture **) &i915->texture[i],
texture[i]);
for (i = num; i < i915->num_textures; i++)
pipe_texture_reference((struct pipe_texture **) &i915->texture[i],
NULL);
i915->num_textures = num;
i915->dirty |= I915_NEW_TEXTURE; i915->dirty |= I915_NEW_TEXTURE;
} }
@@ -691,7 +715,7 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.delete_blend_state = i915_delete_blend_state; i915->pipe.delete_blend_state = i915_delete_blend_state;
i915->pipe.create_sampler_state = i915_create_sampler_state; i915->pipe.create_sampler_state = i915_create_sampler_state;
i915->pipe.bind_sampler_state = i915_bind_sampler_state; i915->pipe.bind_sampler_states = i915_bind_sampler_states;
i915->pipe.delete_sampler_state = i915_delete_sampler_state; i915->pipe.delete_sampler_state = i915_delete_sampler_state;
i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state; i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
@@ -715,7 +739,7 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_scissor_state = i915_set_scissor_state;
i915->pipe.set_sampler_texture = i915_set_sampler_texture; i915->pipe.set_sampler_textures = i915_set_sampler_textures;
i915->pipe.set_viewport_state = i915_set_viewport_state; i915->pipe.set_viewport_state = i915_set_viewport_state;
i915->pipe.set_vertex_buffer = i915_set_vertex_buffer; i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
i915->pipe.set_vertex_element = i915_set_vertex_element; i915->pipe.set_vertex_element = i915_set_vertex_element;

View File

@@ -267,12 +267,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
/* 2 + I915_TEX_UNITS*3 dwords, I915_TEX_UNITS relocs */ /* 2 + I915_TEX_UNITS*3 dwords, I915_TEX_UNITS relocs */
if (i915->hardware_dirty & (I915_HW_MAP | I915_HW_SAMPLER)) if (i915->hardware_dirty & (I915_HW_MAP | I915_HW_SAMPLER))
{ {
/* XXX: we were refering to sampler state
* (current.sampler_enable_nr) below, but only checking
* I915_HW_MAP above. Should probably calculate the enabled
* flags separately - but there will be further rework of
* state so perhaps not necessary yet.
*/
const uint nr = i915->current.sampler_enable_nr; const uint nr = i915->current.sampler_enable_nr;
if (nr) { if (nr) {
const uint enabled = i915->current.sampler_enable_flags; const uint enabled = i915->current.sampler_enable_flags;

View File

@@ -106,7 +106,8 @@ void i915_update_samplers( struct i915_context *i915 )
i915->current.sampler_enable_nr = 0; i915->current.sampler_enable_nr = 0;
i915->current.sampler_enable_flags = 0x0; i915->current.sampler_enable_flags = 0x0;
for (unit = 0; unit < I915_TEX_UNITS; unit++) { for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
unit++) {
/* determine unit enable/disable by looking for a bound texture */ /* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */ /* could also examine the fragment program? */
if (i915->texture[unit]) { if (i915->texture[unit]) {
@@ -219,7 +220,8 @@ i915_update_textures(struct i915_context *i915)
{ {
uint unit; uint unit;
for (unit = 0; unit < I915_TEX_UNITS; unit++) { for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
unit++) {
/* determine unit enable/disable by looking for a bound texture */ /* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */ /* could also examine the fragment program? */
if (i915->texture[unit]) { if (i915->texture[unit]) {

View File

@@ -484,6 +484,9 @@ struct brw_context
const struct brw_texture *Texture[PIPE_MAX_SAMPLERS]; const struct brw_texture *Texture[PIPE_MAX_SAMPLERS];
} attribs; } attribs;
unsigned num_samplers;
unsigned num_textures;
struct brw_mem_pool pool[BRW_MAX_POOL]; struct brw_mem_pool pool[BRW_MAX_POOL];
struct brw_cache cache[BRW_MAX_CACHE]; struct brw_cache cache[BRW_MAX_CACHE];
struct brw_cached_batch_item *cached_batch_items; struct brw_cached_batch_item *cached_batch_items;

View File

@@ -95,12 +95,24 @@ brw_create_sampler_state(struct pipe_context *pipe,
DUP( pipe_sampler_state, sampler ); DUP( pipe_sampler_state, sampler );
} }
static void brw_bind_sampler_state(struct pipe_context *pipe, static void brw_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct brw_context *brw = brw_context(pipe); struct brw_context *brw = brw_context(pipe);
brw->attribs.Samplers[unit] = sampler; assert(num <= PIPE_MAX_SAMPLERS);
/* Check for no-op */
if (num == brw->num_samplers &&
!memcmp(brw->attribs.Samplers, sampler, num * sizeof(void *)))
return;
memcpy(brw->attribs.Samplers, sampler, num * sizeof(void *));
memset(&brw->attribs.Samplers[num], 0, (PIPE_MAX_SAMPLERS - num) *
sizeof(void *));
brw->num_samplers = num;
brw->state.dirty.brw |= BRW_NEW_SAMPLER; brw->state.dirty.brw |= BRW_NEW_SAMPLER;
} }
@@ -330,14 +342,30 @@ static void brw_set_constant_buffer(struct pipe_context *pipe,
*/ */
static void brw_set_sampler_texture(struct pipe_context *pipe, static void brw_set_sampler_textures(struct pipe_context *pipe,
unsigned unit, unsigned num,
struct pipe_texture *texture) struct pipe_texture **texture)
{ {
struct brw_context *brw = brw_context(pipe); struct brw_context *brw = brw_context(pipe);
uint i;
pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[unit], assert(num <= PIPE_MAX_SAMPLERS);
texture);
/* Check for no-op */
if (num == brw->num_textures &&
!memcmp(brw->attribs.Texture, texture, num *
sizeof(struct pipe_texture *)))
return;
for (i = 0; i < num; i++)
pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[i],
texture[i]);
for (i = num; i < brw->num_textures; i++)
pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[i],
NULL);
brw->num_textures = num;
brw->state.dirty.brw |= BRW_NEW_TEXTURE; brw->state.dirty.brw |= BRW_NEW_TEXTURE;
} }
@@ -400,7 +428,7 @@ brw_init_state_functions( struct brw_context *brw )
brw->pipe.delete_blend_state = brw_delete_blend_state; brw->pipe.delete_blend_state = brw_delete_blend_state;
brw->pipe.create_sampler_state = brw_create_sampler_state; brw->pipe.create_sampler_state = brw_create_sampler_state;
brw->pipe.bind_sampler_state = brw_bind_sampler_state; brw->pipe.bind_sampler_states = brw_bind_sampler_states;
brw->pipe.delete_sampler_state = brw_delete_sampler_state; brw->pipe.delete_sampler_state = brw_delete_sampler_state;
brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state; brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
@@ -427,7 +455,7 @@ brw_init_state_functions( struct brw_context *brw )
brw->pipe.set_polygon_stipple = brw_set_polygon_stipple; brw->pipe.set_polygon_stipple = brw_set_polygon_stipple;
brw->pipe.set_scissor_state = brw_set_scissor_state; brw->pipe.set_scissor_state = brw_set_scissor_state;
brw->pipe.set_sampler_texture = brw_set_sampler_texture; brw->pipe.set_sampler_textures = brw_set_sampler_textures;
brw->pipe.set_viewport_state = brw_set_viewport_state; brw->pipe.set_viewport_state = brw_set_viewport_state;
brw->pipe.set_vertex_buffer = brw_set_vertex_buffer; brw->pipe.set_vertex_buffer = brw_set_vertex_buffer;
brw->pipe.set_vertex_element = brw_set_vertex_element; brw->pipe.set_vertex_element = brw_set_vertex_element;

View File

@@ -235,7 +235,8 @@ static void upload_wm_samplers(struct brw_context *brw)
unsigned sampler_count = 0; unsigned sampler_count = 0;
/* BRW_NEW_SAMPLER */ /* BRW_NEW_SAMPLER */
for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) { for (unit = 0; unit < brw->num_textures && unit < brw->num_samplers;
unit++) {
/* determine unit enable/disable by looking for a bound texture */ /* determine unit enable/disable by looking for a bound texture */
if (brw->attribs.Texture[unit]) { if (brw->attribs.Texture[unit]) {
const struct pipe_sampler_state *sampler = brw->attribs.Samplers[unit]; const struct pipe_sampler_state *sampler = brw->attribs.Samplers[unit];

View File

@@ -237,7 +237,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
/* BRW_NEW_TEXTURE /* BRW_NEW_TEXTURE
*/ */
for (i = 0; i < BRW_MAX_TEX_UNIT; i++) { for (i = 0; i < brw->num_textures && i < brw->num_samplers; i++) {
const struct brw_texture *texUnit = brw->attribs.Texture[i]; const struct brw_texture *texUnit = brw->attribs.Texture[i];
if (texUnit && if (texUnit &&

View File

@@ -146,7 +146,7 @@ softpipe_create( struct pipe_screen *screen,
softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
softpipe->pipe.create_sampler_state = softpipe_create_sampler_state; softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state; softpipe->pipe.bind_sampler_states = softpipe_bind_sampler_states;
softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state; softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state; softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;
@@ -171,7 +171,7 @@ softpipe_create( struct pipe_screen *screen,
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
softpipe->pipe.set_sampler_texture = softpipe_set_sampler_texture; softpipe->pipe.set_sampler_textures = softpipe_set_sampler_textures;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer; softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer;

View File

@@ -81,6 +81,9 @@ struct softpipe_context {
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
unsigned dirty; unsigned dirty;
unsigned num_samplers;
unsigned num_textures;
/* Counter for occlusion queries. Note this supports overlapping /* Counter for occlusion queries. Note this supports overlapping
* queries. * queries.
*/ */

View File

@@ -138,9 +138,10 @@ static void shade_begin(struct quad_stage *qs)
struct quad_shade_stage *qss = quad_shade_stage(qs); struct quad_shade_stage *qss = quad_shade_stage(qs);
struct softpipe_context *softpipe = qs->softpipe; struct softpipe_context *softpipe = qs->softpipe;
unsigned i; unsigned i;
unsigned num = MAX2(softpipe->num_textures, softpipe->num_samplers);
/* set TGSI sampler state that varies */ /* set TGSI sampler state that varies */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { for (i = 0; i < num; i++) {
qss->samplers[i].state = softpipe->sampler[i]; qss->samplers[i].state = softpipe->sampler[i];
qss->samplers[i].texture = softpipe->texture[i]; qss->samplers[i].texture = softpipe->texture[i];
} }

View File

@@ -101,7 +101,7 @@ void softpipe_delete_blend_state(struct pipe_context *,
void * void *
softpipe_create_sampler_state(struct pipe_context *, softpipe_create_sampler_state(struct pipe_context *,
const struct pipe_sampler_state *); const struct pipe_sampler_state *);
void softpipe_bind_sampler_state(struct pipe_context *, unsigned, void *); void softpipe_bind_sampler_states(struct pipe_context *, unsigned, void **);
void softpipe_delete_sampler_state(struct pipe_context *, void *); void softpipe_delete_sampler_state(struct pipe_context *, void *);
void * void *
@@ -144,9 +144,9 @@ void softpipe_set_polygon_stipple( struct pipe_context *,
void softpipe_set_scissor_state( struct pipe_context *, void softpipe_set_scissor_state( struct pipe_context *,
const struct pipe_scissor_state * ); const struct pipe_scissor_state * );
void softpipe_set_sampler_texture( struct pipe_context *, void softpipe_set_sampler_textures( struct pipe_context *,
unsigned unit, unsigned num,
struct pipe_texture * ); struct pipe_texture ** );
void softpipe_set_viewport_state( struct pipe_context *, void softpipe_set_viewport_state( struct pipe_context *,
const struct pipe_viewport_state * ); const struct pipe_viewport_state * );

View File

@@ -50,21 +50,61 @@ softpipe_create_sampler_state(struct pipe_context *pipe,
return mem_dup(sampler, sizeof(*sampler)); return mem_dup(sampler, sizeof(*sampler));
} }
void void
softpipe_bind_sampler_state(struct pipe_context *pipe, softpipe_bind_sampler_states(struct pipe_context *pipe,
unsigned unit, void *sampler) unsigned num, void **sampler)
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
assert(num <= PIPE_MAX_SAMPLERS);
/* Check for no-op */
if (num == softpipe->num_samplers &&
!memcmp(softpipe->sampler, sampler, num * sizeof(void *)))
return;
draw_flush(softpipe->draw); draw_flush(softpipe->draw);
assert(unit < PIPE_MAX_SAMPLERS); memcpy(softpipe->sampler, sampler, num * sizeof(void *));
softpipe->sampler[unit] = (struct pipe_sampler_state *)sampler; memset(&softpipe->sampler[num], 0, (PIPE_MAX_SAMPLERS - num) *
sizeof(void *));
softpipe->num_samplers = num;
softpipe->dirty |= SP_NEW_SAMPLER; softpipe->dirty |= SP_NEW_SAMPLER;
} }
void
softpipe_set_sampler_textures(struct pipe_context *pipe,
unsigned num, struct pipe_texture **texture)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
uint i;
assert(num <= PIPE_MAX_SAMPLERS);
/* Check for no-op */
if (num == softpipe->num_textures &&
!memcmp(softpipe->texture, texture, num * sizeof(struct pipe_texture *)))
return;
draw_flush(softpipe->draw);
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
struct pipe_texture *tex = i < num ? texture[i] : NULL;
pipe_texture_reference(&softpipe->texture[i], tex);
sp_tile_cache_set_texture(pipe, softpipe->tex_cache[i], tex);
}
softpipe->num_textures = num;
softpipe->dirty |= SP_NEW_TEXTURE;
}
void void
softpipe_delete_sampler_state(struct pipe_context *pipe, softpipe_delete_sampler_state(struct pipe_context *pipe,
void *sampler) void *sampler)
@@ -73,22 +113,4 @@ softpipe_delete_sampler_state(struct pipe_context *pipe,
} }
void
softpipe_set_sampler_texture(struct pipe_context *pipe,
unsigned unit,
struct pipe_texture *texture)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
draw_flush(softpipe->draw);
assert(unit < PIPE_MAX_SAMPLERS);
pipe_texture_reference(&softpipe->texture[unit], texture);
sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
softpipe->dirty |= SP_NEW_TEXTURE;
}

View File

@@ -178,7 +178,7 @@ softpipe_texture_update(struct pipe_context *pipe,
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
uint unit; uint unit;
for (unit = 0; unit < PIPE_MAX_SAMPLERS; unit++) { for (unit = 0; unit < softpipe->num_textures; unit++) {
if (softpipe->texture[unit] == texture) { if (softpipe->texture[unit] == texture) {
sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]); sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
} }

View File

@@ -100,7 +100,7 @@ struct pipe_context {
void * (*create_sampler_state)(struct pipe_context *, void * (*create_sampler_state)(struct pipe_context *,
const struct pipe_sampler_state *); const struct pipe_sampler_state *);
void (*bind_sampler_state)(struct pipe_context *, unsigned unit, void *); void (*bind_sampler_states)(struct pipe_context *, unsigned num, void **);
void (*delete_sampler_state)(struct pipe_context *, void *); void (*delete_sampler_state)(struct pipe_context *, void *);
void * (*create_rasterizer_state)(struct pipe_context *, void * (*create_rasterizer_state)(struct pipe_context *,
@@ -148,9 +148,9 @@ struct pipe_context {
/* Currently a sampler is constrained to sample from a single texture: /* Currently a sampler is constrained to sample from a single texture:
*/ */
void (*set_sampler_texture)( struct pipe_context *, void (*set_sampler_textures)( struct pipe_context *,
unsigned sampler, unsigned num,
struct pipe_texture * ); struct pipe_texture ** );
void (*set_viewport_state)( struct pipe_context *, void (*set_viewport_state)( struct pipe_context *,
const struct pipe_viewport_state * ); const struct pipe_viewport_state * );

View File

@@ -120,10 +120,11 @@ update_samplers(struct st_context *st)
const struct st_fragment_program *fs = st->fp; const struct st_fragment_program *fs = st->fp;
GLuint su; GLuint su;
st->state.num_samplers = 0;
/* loop over sampler units (aka tex image units) */ /* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) { for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_state sampler; struct pipe_sampler_state sampler;
const struct cso_sampler *cso;
memset(&sampler, 0, sizeof(sampler)); memset(&sampler, 0, sizeof(sampler));
@@ -168,17 +169,16 @@ update_samplers(struct st_context *st)
= st_compare_func_to_pipe(texobj->CompareFunc); = st_compare_func_to_pipe(texobj->CompareFunc);
} }
st->state.num_samplers = su + 1;
/* XXX more sampler state here */ /* XXX more sampler state here */
} }
cso = st_cached_sampler_state(st, &sampler); st->state.sampler[su] = st_cached_sampler_state(st, &sampler)->data;
}
if (cso != st->state.sampler[su]) { st->pipe->bind_sampler_states(st->pipe, st->state.num_samplers,
/* state has changed */ st->state.sampler);
st->state.sampler[su] = cso;
st->pipe->bind_sampler_state(st->pipe, su, cso->data);
}
}
} }

View File

@@ -37,6 +37,7 @@
#include "st_texture.h" #include "st_texture.h"
#include "st_cb_texture.h" #include "st_cb_texture.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_inlines.h"
/** /**
@@ -51,6 +52,8 @@ update_textures(struct st_context *st)
struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
GLuint unit; GLuint unit;
st->state.num_textures = 0;
for (unit = 0; unit < st->ctx->Const.MaxTextureCoordUnits; unit++) { for (unit = 0; unit < st->ctx->Const.MaxTextureCoordUnits; unit++) {
const GLuint su = fprog->Base.SamplerUnits[unit]; const GLuint su = fprog->Base.SamplerUnits[unit];
struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current; struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
@@ -62,6 +65,8 @@ update_textures(struct st_context *st)
retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush); retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
/* XXX retval indicates whether there's a texture border */ /* XXX retval indicates whether there's a texture border */
st->state.num_textures = unit + 1;
} }
/* XXX: need to ensure that textures are unbound/removed from /* XXX: need to ensure that textures are unbound/removed from
@@ -70,18 +75,16 @@ update_textures(struct st_context *st)
*/ */
pt = st_get_stobj_texture(stObj); pt = st_get_stobj_texture(stObj);
pipe_texture_reference(&st->state.sampler_texture[unit], pt);
if (st->state.sampler_texture[unit] != pt) {
st->state.sampler_texture[unit] = pt;
st->pipe->set_sampler_texture(st->pipe, unit, pt);
}
if (stObj && stObj->dirtyData) { if (stObj && stObj->dirtyData) {
st->pipe->texture_update(st->pipe, pt); st->pipe->texture_update(st->pipe, pt);
stObj->dirtyData = GL_FALSE; stObj->dirtyData = GL_FALSE;
} }
} }
st->pipe->set_sampler_textures(st->pipe, st->state.num_textures,
st->state.sampler_texture);
} }

View File

@@ -641,7 +641,6 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
const GLfloat *color, const GLfloat *color,
GLboolean invertTex) GLboolean invertTex)
{ {
const GLuint unit = 0;
struct pipe_context *pipe = ctx->st->pipe; struct pipe_context *pipe = ctx->st->pipe;
GLfloat x0, y0, x1, y1; GLfloat x0, y0, x1, y1;
GLuint maxSize; GLuint maxSize;
@@ -684,7 +683,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler.normalized_coords = 1; sampler.normalized_coords = 1;
cso = st_cached_sampler_state(ctx->st, &sampler); cso = st_cached_sampler_state(ctx->st, &sampler);
pipe->bind_sampler_state(pipe, unit, cso->data); pipe->bind_sampler_states(pipe, 1, (void**)&cso->data);
} }
/* viewport state: viewport matching window dims */ /* viewport state: viewport matching window dims */
@@ -705,7 +704,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* texture state: */ /* texture state: */
{ {
pipe->set_sampler_texture(pipe, unit, pt); pipe->set_sampler_textures(pipe, 1, &pt);
} }
/* Compute window coords (y=0=bottom) with pixel zoom. /* Compute window coords (y=0=bottom) with pixel zoom.
@@ -727,8 +726,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs->data); pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data); pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]); pipe->set_sampler_textures(pipe, ctx->st->state.num_textures,
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data); ctx->st->state.sampler_texture);
pipe->bind_sampler_states(pipe, ctx->st->state.num_samplers,
ctx->st->state.sampler);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport); pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
} }

View File

@@ -76,7 +76,7 @@ struct st_context
struct { struct {
const struct cso_alpha_test *alpha_test; const struct cso_alpha_test *alpha_test;
const struct cso_blend *blend; const struct cso_blend *blend;
const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS]; void *sampler[PIPE_MAX_SAMPLERS];
const struct cso_depth_stencil_alpha *depth_stencil; const struct cso_depth_stencil_alpha *depth_stencil;
const struct cso_rasterizer *rasterizer; const struct cso_rasterizer *rasterizer;
const struct cso_fragment_shader *fs; const struct cso_fragment_shader *fs;
@@ -90,6 +90,9 @@ struct st_context
struct pipe_poly_stipple poly_stipple; struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor; struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport; struct pipe_viewport_state viewport;
GLuint num_samplers;
GLuint num_textures;
} state; } state;
struct { struct {

View File

@@ -284,7 +284,7 @@ st_render_mipmap(struct st_context *st,
*/ */
sampler.min_lod = sampler.max_lod = srcLevel; sampler.min_lod = sampler.max_lod = srcLevel;
sampler_cso = pipe->create_sampler_state(pipe, &sampler); sampler_cso = pipe->create_sampler_state(pipe, &sampler);
pipe->bind_sampler_state(pipe, 0, sampler_cso); pipe->bind_sampler_states(pipe, 1, &sampler_cso);
simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]); simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]);
@@ -293,7 +293,7 @@ st_render_mipmap(struct st_context *st,
* the right mipmap level. * the right mipmap level.
*/ */
/*pt->first_level = srcLevel;*/ /*pt->first_level = srcLevel;*/
pipe->set_sampler_texture(pipe, 0, pt); pipe->set_sampler_textures(pipe, 1, &pt);
draw_quad(st->ctx); draw_quad(st->ctx);
@@ -310,9 +310,10 @@ st_render_mipmap(struct st_context *st,
pipe->bind_fs_state(pipe, st->state.fs->data); pipe->bind_fs_state(pipe, st->state.fs->data);
if (st->state.vs) if (st->state.vs)
pipe->bind_vs_state(pipe, st->state.vs->cso->data); pipe->bind_vs_state(pipe, st->state.vs->cso->data);
if (st->state.sampler[0]) pipe->bind_sampler_states(pipe, st->state.num_samplers,
pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data); st->state.sampler);
pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]); pipe->set_sampler_textures(pipe, st->state.num_textures,
st->state.sampler_texture);
pipe->set_viewport_state(pipe, &st->state.viewport); pipe->set_viewport_state(pipe, &st->state.viewport);
return TRUE; return TRUE;