So that we can handle GS state and other types of shaders in the future.
{
unsigned i;
- if (shader_stage == PIPE_SHADER_VERTEX) {
- debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+ debug_assert(num <= Elements(draw->sampler_views));
+ debug_assert(shader_stage <= PIPE_SHADER_TYPES);
- for (i = 0; i < num; ++i)
- draw->sampler_views[i] = views[i];
- for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
- draw->sampler_views[i] = NULL;
+ for (i = 0; i < num; ++i)
+ draw->sampler_views[shader_stage][i] = views[i];
+ for (i = num; i < Elements(draw->sampler_views); ++i)
+ draw->sampler_views[shader_stage][i] = NULL;
- draw->num_sampler_views = num;
- }
+ draw->num_sampler_views[shader_stage] = num;
}
void
{
unsigned i;
- if (shader_stage == PIPE_SHADER_VERTEX) {
- debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+ debug_assert(num <= Elements(draw->samplers));
+ debug_assert(shader_stage <= PIPE_SHADER_TYPES);
- for (i = 0; i < num; ++i)
- draw->samplers[i] = samplers[i];
- for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
- draw->samplers[i] = NULL;
+ for (i = 0; i < num; ++i)
+ draw->samplers[shader_stage][i] = samplers[i];
+ for (i = num; i < Elements(draw->samplers); ++i)
+ draw->samplers[shader_stage][i] = NULL;
- draw->num_samplers = num;
+ draw->num_samplers[shader_stage] = num;
#ifdef HAVE_LLVM
- if (draw->llvm)
- draw_llvm_set_sampler_state(draw);
+ if (draw->llvm && shader_stage == PIPE_SHADER_VERTEX)
+ draw_llvm_set_sampler_state(draw);
#endif
- }
}
void
for (i = 0 ; i < key->nr_samplers; i++) {
lp_sampler_static_state(&sampler[i],
- llvm->draw->sampler_views[i],
- llvm->draw->samplers[i]);
+ llvm->draw->sampler_views[PIPE_SHADER_VERTEX][i],
+ llvm->draw->samplers[PIPE_SHADER_VERTEX][i]);
}
return key;
{
unsigned i;
- for (i = 0; i < draw->num_samplers; i++) {
+ for (i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) {
struct draw_jit_texture *jit_tex = &draw->llvm->jit_context.textures[i];
if (draw->samplers[i]) {
- jit_tex->min_lod = draw->samplers[i]->min_lod;
- jit_tex->max_lod = draw->samplers[i]->max_lod;
- jit_tex->lod_bias = draw->samplers[i]->lod_bias;
- COPY_4V(jit_tex->border_color, draw->samplers[i]->border_color.f);
+ const struct pipe_sampler_state *s
+ = draw->samplers[PIPE_SHADER_VERTEX][i];
+ jit_tex->min_lod = s->min_lod;
+ jit_tex->max_lod = s->max_lod;
+ jit_tex->lod_bias = s->lod_bias;
+ COPY_4V(jit_tex->border_color, s->border_color.f);
}
}
}
struct draw_llvm *llvm;
#endif
- struct pipe_sampler_view *sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
- unsigned num_sampler_views;
- const struct pipe_sampler_state *samplers[PIPE_MAX_VERTEX_SAMPLERS];
- unsigned num_samplers;
+ /** Texture sampler and sampler view state.
+ * Note that we have arrays indexed by shader type. At this time
+ * we only handle vertex and geometry shaders in the draw module, but
+ * there may be more in the future (ex: hull and tessellation).
+ */
+ struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ unsigned num_sampler_views[PIPE_SHADER_TYPES];
+ const struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ unsigned num_samplers[PIPE_SHADER_TYPES];
void *driver_private;
};