summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-08-02 13:02:40 -0600
committerBrian Paul <[email protected]>2012-08-03 07:16:35 -0600
commitea6f035ae90895bd4ee3247408eb179dfdf96d22 (patch)
tree19df9d3c7b12cb641cea4ccb84950c09992c1732 /src/mesa/state_tracker
parent350f12fb657a2ac860796c179233fa357e4bf46c (diff)
gallium: consolidate CSO sampler and sampler_view functions
Merge the vertex/fragment versions of the cso_set/save/restore_samplers() functions. Now we pass the shader stage (PIPE_SHADER_x) to the function to indicate vertex/fragment/geometry samplers. For example: cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, unit, sampler); This results in quite a bit of code reduction, fewer CSO functions and support for geometry shaders. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c12
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c14
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c13
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c16
4 files changed, 29 insertions, 26 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index dc0c789c5c6..84fbd9d4651 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -219,12 +219,12 @@ update_vertex_samplers(struct st_context *st)
st->state.num_vertex_samplers = su + 1;
- cso_single_vertex_sampler(st->cso_context, su, sampler);
+ cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, sampler);
} else {
- cso_single_vertex_sampler(st->cso_context, su, NULL);
+ cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, NULL);
}
}
- cso_single_vertex_sampler_done(st->cso_context);
+ cso_single_sampler_done(st->cso_context, PIPE_SHADER_VERTEX);
}
@@ -253,18 +253,18 @@ update_fragment_samplers(struct st_context *st)
st->state.num_samplers = su + 1;
/*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
- cso_single_sampler(st->cso_context, su, sampler);
+ cso_single_sampler(st->cso_context, PIPE_SHADER_FRAGMENT, su, sampler);
}
else if (samplers_used != 0 || su < old_max) {
/*printf("%s su=%u null\n", __FUNCTION__, su);*/
- cso_single_sampler(st->cso_context, su, NULL);
+ cso_single_sampler(st->cso_context, PIPE_SHADER_FRAGMENT, su, NULL);
} else {
/* if we've reset all the old views and we have no more new ones */
break;
}
}
- cso_single_sampler_done(st->cso_context);
+ cso_single_sampler_done(st->cso_context, PIPE_SHADER_FRAGMENT);
}
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fefa5986096..f5db65ae120 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -288,9 +288,10 @@ update_vertex_textures(struct st_context *st)
if (ctx->Const.MaxVertexTextureImageUnits > 0) {
GLuint numUnits = MIN2(st->state.num_vertex_textures,
ctx->Const.MaxVertexTextureImageUnits);
- cso_set_vertex_sampler_views(st->cso_context,
- numUnits,
- st->state.sampler_vertex_views);
+ cso_set_sampler_views(st->cso_context,
+ PIPE_SHADER_VERTEX,
+ numUnits,
+ st->state.sampler_vertex_views);
}
}
@@ -329,9 +330,10 @@ update_fragment_textures(struct st_context *st)
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}
- cso_set_fragment_sampler_views(st->cso_context,
- st->state.num_textures,
- st->state.sampler_views);
+ cso_set_sampler_views(st->cso_context,
+ PIPE_SHADER_FRAGMENT,
+ st->state.num_textures,
+ st->state.sampler_views);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index c2605887428..131efcabc6b 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -454,8 +454,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
assert(height <= (GLsizei)maxSize);
cso_save_rasterizer(cso);
- cso_save_samplers(cso);
- cso_save_fragment_sampler_views(cso);
+ cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
cso_save_viewport(cso);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
@@ -487,7 +487,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
}
samplers[fpv->bitmap_sampler] =
&st->bitmap.samplers[sv->texture->target != PIPE_TEXTURE_RECT];
- cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers);
+ cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num,
+ (const struct pipe_sampler_state **) samplers);
}
/* user textures, plus the bitmap texture */
@@ -496,7 +497,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_textures);
memcpy(sampler_views, st->state.sampler_views, sizeof(sampler_views));
sampler_views[fpv->bitmap_sampler] = sv;
- cso_set_fragment_sampler_views(cso, num, sampler_views);
+ cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
}
/* viewport state: viewport matching window dims */
@@ -535,8 +536,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* restore state */
cso_restore_rasterizer(cso);
- cso_restore_samplers(cso);
- cso_restore_fragment_sampler_views(cso);
+ cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
cso_restore_viewport(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index f288a963244..88068ac6078 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -679,8 +679,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_rasterizer(cso);
cso_save_viewport(cso);
- cso_save_samplers(cso);
- cso_save_fragment_sampler_views(cso);
+ cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
@@ -751,11 +751,11 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler.normalized_coords = normalized;
- cso_single_sampler(cso, 0, &sampler);
+ cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, 0, &sampler);
if (num_sampler_view > 1) {
- cso_single_sampler(cso, 1, &sampler);
+ cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, 1, &sampler);
}
- cso_single_sampler_done(cso);
+ cso_single_sampler_done(cso, PIPE_SHADER_FRAGMENT);
}
/* viewport state: viewport matching window dims */
@@ -778,7 +778,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
/* texture state: */
- cso_set_fragment_sampler_views(cso, num_sampler_view, sv);
+ cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
/* Compute Gallium window coords (y=0=top) with pixel zoom.
* Recall that these coords are transformed by the current
@@ -804,8 +804,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* restore state */
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
- cso_restore_samplers(cso);
- cso_restore_fragment_sampler_views(cso);
+ cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
cso_restore_geometry_shader(cso);