static void i915_set_vertex_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) { struct i915_context *i915 = i915_context(pipe); uint i; assert(num <= Elements(i915->vertex_sampler_views)); /* Check for no-op */ if (num == i915->num_vertex_sampler_views && !memcmp(i915->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { return; } for (i = 0; i < Elements(i915->vertex_sampler_views); i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; pipe_sampler_view_reference(&i915->vertex_sampler_views[i], view); } i915->num_vertex_sampler_views = num; draw_set_sampler_views(i915->draw, PIPE_SHADER_VERTEX, i915->vertex_sampler_views, i915->num_vertex_sampler_views); }
static void llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; assert(num <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ if (num == llvmpipe->num_vertex_sampler_views && !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { return; } draw_flush(llvmpipe->draw); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view); } llvmpipe->num_vertex_sampler_views = num; draw_set_sampler_views(llvmpipe->draw, llvmpipe->vertex_sampler_views, llvmpipe->num_vertex_sampler_views); llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; }
void softpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; assert(shader < PIPE_SHADER_TYPES); assert(start + num <= ARRAY_SIZE(softpipe->sampler_views[shader])); draw_flush(softpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { struct sp_sampler_view *sp_sviewsrc; struct sp_sampler_view *sp_sviewdst = &softpipe->tgsi.sampler[shader]->sp_sview[start + i]; struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i]; pipe_sampler_view_reference(pview, views[i]); sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i], views[i]); /* * We don't really have variants, however some bits are different per shader, * so just copy? */ sp_sviewsrc = (struct sp_sampler_view *)*pview; if (sp_sviewsrc) { memcpy(sp_sviewdst, sp_sviewsrc, sizeof(*sp_sviewsrc)); sp_sviewdst->compute_lambda = softpipe_get_lambda_func(&sp_sviewdst->base, shader); sp_sviewdst->cache = softpipe->tex_cache[shader][start + i]; } else { memset(sp_sviewdst, 0, sizeof(*sp_sviewsrc)); } } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(softpipe->num_sampler_views[shader], start + num); while (j > 0 && softpipe->sampler_views[shader][j - 1] == NULL) j--; softpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(softpipe->draw, shader, softpipe->sampler_views[shader], softpipe->num_sampler_views[shader]); } softpipe->dirty |= SP_NEW_TEXTURE; }
static void llvmpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(shader < PIPE_SHADER_TYPES); assert(start + num <= Elements(llvmpipe->sampler_views[shader])); draw_flush(llvmpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { /* Note: we're using pipe_sampler_view_release() here to work around * a possible crash when the old view belongs to another context that * was already destroyed. */ pipe_sampler_view_release(pipe, &llvmpipe->sampler_views[shader][start + i]); /* * Warn if someone tries to set a view created in a different context * (which is why we need the hack above in the first place). * An assert would be better but st/mesa relies on it... */ if (views[i] && views[i]->context != pipe) { debug_printf("Illegal setting of sampler_view %d created in another " "context\n", i); } pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i], views[i]); } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(llvmpipe->num_sampler_views[shader], start + num); while (j > 0 && llvmpipe->sampler_views[shader][j - 1] == NULL) j--; llvmpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(llvmpipe->draw, shader, llvmpipe->sampler_views[shader], llvmpipe->num_sampler_views[shader]); } else { llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; } }
static void softpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; assert(shader < PIPE_SHADER_TYPES); assert(start + num <= Elements(softpipe->sampler_views[shader])); /* Check for no-op */ if (start + num <= softpipe->num_sampler_views[shader] && !memcmp(softpipe->sampler_views[shader] + start, views, num * sizeof(struct pipe_sampler_view *))) { return; } draw_flush(softpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { pipe_sampler_view_reference(&softpipe->sampler_views[shader][start + i], views[i]); sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i], views[i]); } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(softpipe->num_sampler_views[shader], start + num); while (j > 0 && softpipe->sampler_views[shader][j - 1] == NULL) j--; softpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(softpipe->draw, shader, softpipe->sampler_views[shader], softpipe->num_sampler_views[shader]); } softpipe->dirty |= SP_NEW_TEXTURE; }
static void llvmpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(shader < PIPE_SHADER_TYPES); assert(start + num <= Elements(llvmpipe->sampler_views[shader])); draw_flush(llvmpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { /* Note: we're using pipe_sampler_view_release() here to work around * a possible crash when the old view belongs to another context that * was already destroyed. */ pipe_sampler_view_release(pipe, &llvmpipe->sampler_views[shader][start + i]); pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i], views[i]); } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(llvmpipe->num_sampler_views[shader], start + num); while (j > 0 && llvmpipe->sampler_views[shader][j - 1] == NULL) j--; llvmpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(llvmpipe->draw, shader, llvmpipe->sampler_views[shader], llvmpipe->num_sampler_views[shader]); } llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; }