st/mesa: don't store non-fragment sampler states and views in st_context
those are unused. st_context: 10120 -> 3704 bytes Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -258,13 +258,18 @@ update_shader_samplers(struct st_context *st,
|
||||
GLbitfield free_slots = ~prog->SamplersUsed;
|
||||
GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
|
||||
unsigned unit, num_samplers;
|
||||
struct pipe_sampler_state local_samplers[PIPE_MAX_SAMPLERS];
|
||||
const struct pipe_sampler_state *states[PIPE_MAX_SAMPLERS];
|
||||
|
||||
if (samplers_used == 0x0) {
|
||||
if (out_num_samplers)
|
||||
*out_num_samplers = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!samplers)
|
||||
samplers = local_samplers;
|
||||
|
||||
num_samplers = util_last_bit(samplers_used);
|
||||
|
||||
/* loop over sampler units (aka tex image units) */
|
||||
@@ -320,6 +325,8 @@ update_shader_samplers(struct st_context *st,
|
||||
}
|
||||
|
||||
cso_set_samplers(st->cso_context, shader_stage, num_samplers, states);
|
||||
|
||||
if (out_num_samplers)
|
||||
*out_num_samplers = num_samplers;
|
||||
}
|
||||
|
||||
@@ -331,9 +338,7 @@ st_update_vertex_samplers(struct st_context *st)
|
||||
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_VERTEX,
|
||||
ctx->VertexProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_VERTEX],
|
||||
&st->state.num_samplers[PIPE_SHADER_VERTEX]);
|
||||
ctx->VertexProgram._Current, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,9 +350,7 @@ st_update_tessctrl_samplers(struct st_context *st)
|
||||
if (ctx->TessCtrlProgram._Current) {
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_TESS_CTRL,
|
||||
ctx->TessCtrlProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_TESS_CTRL],
|
||||
&st->state.num_samplers[PIPE_SHADER_TESS_CTRL]);
|
||||
ctx->TessCtrlProgram._Current, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,9 +363,7 @@ st_update_tesseval_samplers(struct st_context *st)
|
||||
if (ctx->TessEvalProgram._Current) {
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_TESS_EVAL,
|
||||
ctx->TessEvalProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_TESS_EVAL],
|
||||
&st->state.num_samplers[PIPE_SHADER_TESS_EVAL]);
|
||||
ctx->TessEvalProgram._Current, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,9 +376,7 @@ st_update_geometry_samplers(struct st_context *st)
|
||||
if (ctx->GeometryProgram._Current) {
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_GEOMETRY,
|
||||
ctx->GeometryProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_GEOMETRY],
|
||||
&st->state.num_samplers[PIPE_SHADER_GEOMETRY]);
|
||||
ctx->GeometryProgram._Current, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,8 +389,8 @@ st_update_fragment_samplers(struct st_context *st)
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_FRAGMENT,
|
||||
ctx->FragmentProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_FRAGMENT],
|
||||
&st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
|
||||
st->state.frag_samplers,
|
||||
&st->state.num_frag_samplers);
|
||||
}
|
||||
|
||||
|
||||
@@ -403,8 +402,6 @@ st_update_compute_samplers(struct st_context *st)
|
||||
if (ctx->ComputeProgram._Current) {
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_COMPUTE,
|
||||
ctx->ComputeProgram._Current,
|
||||
st->state.samplers[PIPE_SHADER_COMPUTE],
|
||||
&st->state.num_samplers[PIPE_SHADER_COMPUTE]);
|
||||
ctx->ComputeProgram._Current, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
@@ -216,7 +216,21 @@ update_textures(struct st_context *st,
|
||||
*out_num_textures = num_textures;
|
||||
}
|
||||
|
||||
/* Same as update_textures, but don't store the views in st_context. */
|
||||
static void
|
||||
update_textures_local(struct st_context *st,
|
||||
enum pipe_shader_type shader_stage,
|
||||
const struct gl_program *prog,
|
||||
unsigned *out_num_textures)
|
||||
{
|
||||
struct pipe_sampler_view *local_views[PIPE_MAX_SAMPLERS] = {0};
|
||||
|
||||
update_textures(st, shader_stage, prog, local_views, out_num_textures);
|
||||
|
||||
unsigned num = *out_num_textures;
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
pipe_sampler_view_reference(&local_views[i], NULL);
|
||||
}
|
||||
|
||||
void
|
||||
st_update_vertex_textures(struct st_context *st)
|
||||
@@ -224,10 +238,8 @@ st_update_vertex_textures(struct st_context *st)
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
|
||||
update_textures(st,
|
||||
PIPE_SHADER_VERTEX,
|
||||
update_textures_local(st, PIPE_SHADER_VERTEX,
|
||||
ctx->VertexProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_VERTEX],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
|
||||
}
|
||||
}
|
||||
@@ -241,7 +253,7 @@ st_update_fragment_textures(struct st_context *st)
|
||||
update_textures(st,
|
||||
PIPE_SHADER_FRAGMENT,
|
||||
ctx->FragmentProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_FRAGMENT],
|
||||
st->state.frag_sampler_views,
|
||||
&st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
|
||||
}
|
||||
|
||||
@@ -252,10 +264,8 @@ st_update_geometry_textures(struct st_context *st)
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->GeometryProgram._Current) {
|
||||
update_textures(st,
|
||||
PIPE_SHADER_GEOMETRY,
|
||||
update_textures_local(st, PIPE_SHADER_GEOMETRY,
|
||||
ctx->GeometryProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_GEOMETRY],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]);
|
||||
}
|
||||
}
|
||||
@@ -267,10 +277,8 @@ st_update_tessctrl_textures(struct st_context *st)
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->TessCtrlProgram._Current) {
|
||||
update_textures(st,
|
||||
PIPE_SHADER_TESS_CTRL,
|
||||
update_textures_local(st, PIPE_SHADER_TESS_CTRL,
|
||||
ctx->TessCtrlProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_TESS_CTRL],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]);
|
||||
}
|
||||
}
|
||||
@@ -282,10 +290,8 @@ st_update_tesseval_textures(struct st_context *st)
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->TessEvalProgram._Current) {
|
||||
update_textures(st,
|
||||
PIPE_SHADER_TESS_EVAL,
|
||||
update_textures_local(st, PIPE_SHADER_TESS_EVAL,
|
||||
ctx->TessEvalProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_TESS_EVAL],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_TESS_EVAL]);
|
||||
}
|
||||
}
|
||||
@@ -297,10 +303,8 @@ st_update_compute_textures(struct st_context *st)
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->ComputeProgram._Current) {
|
||||
update_textures(st,
|
||||
PIPE_SHADER_COMPUTE,
|
||||
update_textures_local(st, PIPE_SHADER_COMPUTE,
|
||||
ctx->ComputeProgram._Current,
|
||||
st->state.sampler_views[PIPE_SHADER_COMPUTE],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_COMPUTE]);
|
||||
}
|
||||
}
|
||||
|
@@ -224,10 +224,10 @@ setup_render_state(struct gl_context *ctx,
|
||||
{
|
||||
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
|
||||
uint num = MAX2(fpv->bitmap_sampler + 1,
|
||||
st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
|
||||
st->state.num_frag_samplers);
|
||||
uint i;
|
||||
for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++) {
|
||||
samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i];
|
||||
for (i = 0; i < st->state.num_frag_samplers; i++) {
|
||||
samplers[i] = &st->state.frag_samplers[i];
|
||||
}
|
||||
if (atlas)
|
||||
samplers[fpv->bitmap_sampler] = &st->bitmap.atlas_sampler;
|
||||
@@ -242,7 +242,7 @@ setup_render_state(struct gl_context *ctx,
|
||||
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
|
||||
uint num = MAX2(fpv->bitmap_sampler + 1,
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
|
||||
memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
|
||||
memcpy(sampler_views, st->state.frag_sampler_views,
|
||||
sizeof(sampler_views));
|
||||
sampler_views[fpv->bitmap_sampler] = sv;
|
||||
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
|
||||
|
@@ -736,11 +736,11 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
||||
const struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
|
||||
uint num = MAX3(fpv->drawpix_sampler + 1,
|
||||
fpv->pixelmap_sampler + 1,
|
||||
st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
|
||||
st->state.num_frag_samplers);
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++)
|
||||
samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i];
|
||||
for (i = 0; i < st->state.num_frag_samplers; i++)
|
||||
samplers[i] = &st->state.frag_samplers[i];
|
||||
|
||||
samplers[fpv->drawpix_sampler] = &sampler;
|
||||
if (sv[1])
|
||||
@@ -763,7 +763,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
||||
fpv->pixelmap_sampler + 1,
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
|
||||
|
||||
memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
|
||||
memcpy(sampler_views, st->state.frag_sampler_views,
|
||||
sizeof(sampler_views));
|
||||
|
||||
sampler_views[fpv->drawpix_sampler] = sv[0];
|
||||
|
@@ -254,7 +254,7 @@ st_invalidate_state(struct gl_context *ctx)
|
||||
static void
|
||||
st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
|
||||
{
|
||||
uint shader, i;
|
||||
uint i;
|
||||
|
||||
st_destroy_atoms(st);
|
||||
st_destroy_draw(st);
|
||||
@@ -267,11 +267,9 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
|
||||
st_destroy_bound_texture_handles(st);
|
||||
st_destroy_bound_image_handles(st);
|
||||
|
||||
for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) {
|
||||
for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(st->state.frag_sampler_views); i++) {
|
||||
pipe_sampler_view_release(st->pipe,
|
||||
&st->state.sampler_views[shader][i]);
|
||||
}
|
||||
&st->state.frag_sampler_views[i]);
|
||||
}
|
||||
|
||||
/* free glReadPixels cache data */
|
||||
|
@@ -151,9 +151,9 @@ struct st_context
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_depth_stencil_alpha_state depth_stencil;
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_sampler_state samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
|
||||
GLuint num_samplers[PIPE_SHADER_TYPES];
|
||||
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
|
||||
struct pipe_sampler_state frag_samplers[PIPE_MAX_SAMPLERS];
|
||||
GLuint num_frag_samplers;
|
||||
struct pipe_sampler_view *frag_sampler_views[PIPE_MAX_SAMPLERS];
|
||||
GLuint num_sampler_views[PIPE_SHADER_TYPES];
|
||||
struct pipe_clip_state clip;
|
||||
struct {
|
||||
|
Reference in New Issue
Block a user