summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Verbeet <[email protected]>2011-01-19 19:11:05 -0700
committerBrian Paul <[email protected]>2011-01-19 21:47:27 -0700
commit21148e6a8806736b4487da41b01e2d3c01cbc743 (patch)
treeab747977253b5026aaaa6867df14a09280fadd02
parent54fdc351ddbda68bd6ef75021dafcdf8654a4342 (diff)
softpipe: Bind samplers to views instead of the underlying resource.
Signed-off-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c41
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c41
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.h8
5 files changed, 39 insertions, 55 deletions
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index db02d0eae24..2ee21817031 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -106,7 +106,7 @@ softpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
sp_destroy_tex_tile_cache(softpipe->fragment_tex_cache[i]);
- pipe_sampler_view_reference(&softpipe->sampler_views[i], NULL);
+ pipe_sampler_view_reference(&softpipe->fragment_sampler_views[i], NULL);
}
for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 6e20b433611..035d712d17c 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -77,7 +77,7 @@ struct softpipe_context {
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
struct pipe_sampler_view *geometry_sampler_views[PIPE_MAX_GEOMETRY_SAMPLERS];
struct pipe_viewport_state viewport;
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 7becd6e9d7b..38943563800 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -192,7 +192,8 @@ softpipe_set_fragment_sampler_views(struct pipe_context *pipe,
/* Check for no-op */
if (num == softpipe->num_sampler_views &&
- !memcmp(softpipe->sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
+ !memcmp(softpipe->fragment_sampler_views, views,
+ num * sizeof(struct pipe_sampler_view *)))
return;
draw_flush(softpipe->draw);
@@ -200,7 +201,7 @@ softpipe_set_fragment_sampler_views(struct pipe_context *pipe,
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
struct pipe_sampler_view *view = i < num ? views[i] : NULL;
- pipe_sampler_view_reference(&softpipe->sampler_views[i], view);
+ pipe_sampler_view_reference(&softpipe->fragment_sampler_views[i], view);
sp_tex_tile_cache_set_sampler_view(softpipe->fragment_tex_cache[i], view);
}
@@ -342,33 +343,21 @@ softpipe_reset_sampler_variants(struct softpipe_context *softpipe)
*/
for (i = 0; i <= softpipe->vs->max_sampler; i++) {
if (softpipe->vertex_samplers[i]) {
- struct pipe_resource *texture = NULL;
-
- if (softpipe->vertex_sampler_views[i]) {
- texture = softpipe->vertex_sampler_views[i]->texture;
- }
-
softpipe->tgsi.vert_samplers_list[i] =
get_sampler_variant( i,
sp_sampler(softpipe->vertex_samplers[i]),
softpipe->vertex_sampler_views[i],
TGSI_PROCESSOR_VERTEX );
- sp_sampler_variant_bind_texture( softpipe->tgsi.vert_samplers_list[i],
- softpipe->vertex_tex_cache[i],
- texture );
+ sp_sampler_variant_bind_view( softpipe->tgsi.vert_samplers_list[i],
+ softpipe->vertex_tex_cache[i],
+ softpipe->vertex_sampler_views[i] );
}
}
if (softpipe->gs) {
for (i = 0; i <= softpipe->gs->max_sampler; i++) {
if (softpipe->geometry_samplers[i]) {
- struct pipe_resource *texture = NULL;
-
- if (softpipe->geometry_sampler_views[i]) {
- texture = softpipe->geometry_sampler_views[i]->texture;
- }
-
softpipe->tgsi.geom_samplers_list[i] =
get_sampler_variant(
i,
@@ -376,31 +365,25 @@ softpipe_reset_sampler_variants(struct softpipe_context *softpipe)
softpipe->geometry_sampler_views[i],
TGSI_PROCESSOR_GEOMETRY );
- sp_sampler_variant_bind_texture(
+ sp_sampler_variant_bind_view(
softpipe->tgsi.geom_samplers_list[i],
softpipe->geometry_tex_cache[i],
- texture );
+ softpipe->geometry_sampler_views[i] );
}
}
}
for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) {
if (softpipe->sampler[i]) {
- struct pipe_resource *texture = NULL;
-
- if (softpipe->sampler_views[i]) {
- texture = softpipe->sampler_views[i]->texture;
- }
-
softpipe->tgsi.frag_samplers_list[i] =
get_sampler_variant( i,
sp_sampler(softpipe->sampler[i]),
- softpipe->sampler_views[i],
+ softpipe->fragment_sampler_views[i],
TGSI_PROCESSOR_FRAGMENT );
- sp_sampler_variant_bind_texture( softpipe->tgsi.frag_samplers_list[i],
- softpipe->fragment_tex_cache[i],
- texture );
+ sp_sampler_variant_bind_view( softpipe->tgsi.frag_samplers_list[i],
+ softpipe->fragment_tex_cache[i],
+ softpipe->fragment_sampler_views[i] );
}
}
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index cbc40d4b446..242c27c7ebd 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -550,7 +550,7 @@ compute_lambda_1d(const struct sp_sampler_variant *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float rho = MAX2(dsdx, dsdy) * texture->width0;
@@ -565,7 +565,7 @@ compute_lambda_2d(const struct sp_sampler_variant *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]);
@@ -584,7 +584,7 @@ compute_lambda_3d(const struct sp_sampler_variant *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]);
@@ -654,7 +654,7 @@ static INLINE const float *
get_texel_2d(const struct sp_sampler_variant *samp,
union tex_tile_address addr, int x, int y)
{
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level = addr.bits.level;
if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
@@ -747,7 +747,7 @@ static INLINE const float *
get_texel_3d(const struct sp_sampler_variant *samp,
union tex_tile_address addr, int x, int y, int z)
{
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level = addr.bits.level;
if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
@@ -959,7 +959,7 @@ img_filter_1d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width;
int x[4];
@@ -999,7 +999,7 @@ img_filter_2d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width, height;
int x[4], y[4];
@@ -1051,7 +1051,7 @@ img_filter_cube_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
const unsigned *faces = samp->faces; /* zero when not cube-mapping */
unsigned level0, j;
int width, height;
@@ -1095,7 +1095,7 @@ img_filter_3d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width, height, depth;
int x[4], y[4], z[4];
@@ -1137,7 +1137,7 @@ img_filter_1d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width;
int x0[4], x1[4];
@@ -1177,7 +1177,7 @@ img_filter_2d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width, height;
int x0[4], y0[4], x1[4], y1[4];
@@ -1224,7 +1224,7 @@ img_filter_cube_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
const unsigned *faces = samp->faces; /* zero when not cube-mapping */
unsigned level0, j;
int width, height;
@@ -1273,7 +1273,7 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
unsigned level0, j;
int width, height, depth;
int x0[4], x1[4], y0[4], y1[4], z0[4], z1[4];
@@ -1349,7 +1349,7 @@ mip_filter_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
int level0;
float lambda;
float lod[QUAD_SIZE];
@@ -1416,7 +1416,7 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
float lambda;
float lod[QUAD_SIZE];
@@ -1500,7 +1500,7 @@ mip_filter_linear_2d_linear_repeat_POT(
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler);
- const struct pipe_resource *texture = samp->texture;
+ const struct pipe_resource *texture = samp->view->texture;
int level0;
float lambda;
float lod[QUAD_SIZE];
@@ -1990,13 +1990,14 @@ get_img_filter(const union sp_sampler_key key,
* Bind the given texture object and texture cache to the sampler variant.
*/
void
-sp_sampler_variant_bind_texture( struct sp_sampler_variant *samp,
- struct softpipe_tex_tile_cache *tex_cache,
- const struct pipe_resource *texture )
+sp_sampler_variant_bind_view( struct sp_sampler_variant *samp,
+ struct softpipe_tex_tile_cache *tex_cache,
+ const struct pipe_sampler_view *view )
{
const struct pipe_sampler_state *sampler = samp->sampler;
+ const struct pipe_resource *texture = view->texture;
- samp->texture = texture;
+ samp->view = view;
samp->cache = tex_cache;
samp->xpot = util_unsigned_logbase2( texture->width0 );
samp->ypot = util_unsigned_logbase2( texture->height0 );
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h
index ed99006ab02..f0b867edc6e 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.h
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.h
@@ -89,7 +89,7 @@ struct sp_sampler_variant
/* Currently bound texture:
*/
- const struct pipe_resource *texture;
+ const struct pipe_sampler_view *view;
struct softpipe_tex_tile_cache *cache;
unsigned processor;
@@ -132,9 +132,9 @@ struct sp_sampler_variant *
sp_create_sampler_variant( const struct pipe_sampler_state *sampler,
const union sp_sampler_key key );
-void sp_sampler_variant_bind_texture( struct sp_sampler_variant *variant,
- struct softpipe_tex_tile_cache *tex_cache,
- const struct pipe_resource *tex );
+void sp_sampler_variant_bind_view( struct sp_sampler_variant *variant,
+ struct softpipe_tex_tile_cache *tex_cache,
+ const struct pipe_sampler_view *view );
void sp_sampler_variant_destroy( struct sp_sampler_variant * );