155
155
/* Check for no-op */
156
156
if (num == svga->curr.num_samplers &&
157
157
!memcmp(svga->curr.sampler, sampler, num * sizeof(void *))) {
158
debug_printf("sampler noop\n");
158
if (0) debug_printf("sampler noop\n");
179
static void svga_set_sampler_textures(struct pipe_context *pipe,
181
struct pipe_texture **texture)
179
static struct pipe_sampler_view *
180
svga_create_sampler_view(struct pipe_context *pipe,
181
struct pipe_resource *texture,
182
const struct pipe_sampler_view *templ)
184
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
188
view->reference.count = 1;
189
view->texture = NULL;
190
pipe_resource_reference(&view->texture, texture);
191
view->context = pipe;
199
svga_sampler_view_destroy(struct pipe_context *pipe,
200
struct pipe_sampler_view *view)
202
pipe_resource_reference(&view->texture, NULL);
206
static void svga_set_sampler_views(struct pipe_context *pipe,
208
struct pipe_sampler_view **views)
183
210
struct svga_context *svga = svga_context(pipe);
184
211
unsigned flag_1d = 0;
188
215
assert(num <= PIPE_MAX_SAMPLERS);
190
217
/* Check for no-op */
191
if (num == svga->curr.num_textures &&
192
!memcmp(svga->curr.texture, texture, num * sizeof(struct pipe_texture *))) {
218
if (num == svga->curr.num_sampler_views &&
219
!memcmp(svga->curr.sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
193
220
if (0) debug_printf("texture noop\n");
197
224
for (i = 0; i < num; i++) {
198
pipe_texture_reference(&svga->curr.texture[i],
225
pipe_sampler_view_reference(&svga->curr.sampler_views[i],
204
if (texture[i]->format == PIPE_FORMAT_B8G8R8A8_SRGB)
231
if (views[i]->texture->format == PIPE_FORMAT_B8G8R8A8_SRGB)
205
232
flag_srgb |= 1 << i;
207
if (texture[i]->target == PIPE_TEXTURE_1D)
234
if (views[i]->texture->target == PIPE_TEXTURE_1D)
208
235
flag_1d |= 1 << i;
211
for (i = num; i < svga->curr.num_textures; i++)
212
pipe_texture_reference(&svga->curr.texture[i],
238
for (i = num; i < svga->curr.num_sampler_views; i++)
239
pipe_sampler_view_reference(&svga->curr.sampler_views[i],
215
svga->curr.num_textures = num;
242
svga->curr.num_sampler_views = num;
216
243
svga->dirty |= SVGA_NEW_TEXTURE_BINDING;
218
245
if (flag_srgb != svga->curr.tex_flags.flag_srgb ||
231
258
svga->pipe.create_sampler_state = svga_create_sampler_state;
232
259
svga->pipe.bind_fragment_sampler_states = svga_bind_sampler_states;
233
260
svga->pipe.delete_sampler_state = svga_delete_sampler_state;
234
svga->pipe.set_fragment_sampler_textures = svga_set_sampler_textures;
261
svga->pipe.set_fragment_sampler_views = svga_set_sampler_views;
262
svga->pipe.create_sampler_view = svga_create_sampler_view;
263
svga->pipe.sampler_view_destroy = svga_sampler_view_destroy;