2 * Copyright © 2014-2017 Broadcom
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include "util/u_format.h"
26 #include "util/u_math.h"
27 #include "util/u_memory.h"
28 #include "util/ralloc.h"
29 #include "util/hash_table.h"
30 #include "util/u_upload_mgr.h"
31 #include "tgsi/tgsi_dump.h"
32 #include "tgsi/tgsi_parse.h"
33 #include "compiler/nir/nir.h"
34 #include "compiler/nir/nir_builder.h"
35 #include "nir/tgsi_to_nir.h"
36 #include "compiler/v3d_compiler.h"
37 #include "v3d_context.h"
38 #include "broadcom/cle/v3d_packet_v33_pack.h"
39 #include "mesa/state_tracker/st_glsl_types.h"
41 static gl_varying_slot
42 v3d_get_slot_for_driver_location(nir_shader
*s
, uint32_t driver_location
)
44 nir_foreach_variable(var
, &s
->outputs
) {
45 if (var
->data
.driver_location
== driver_location
) {
46 return var
->data
.location
;
54 * Precomputes the TRANSFORM_FEEDBACK_OUTPUT_DATA_SPEC array for the shader.
56 * A shader can have 16 of these specs, and each one of them can write up to
57 * 16 dwords. Since we allow a total of 64 transform feedback output
58 * components (not 16 vectors), we have to group the writes of multiple
59 * varyings together in a single data spec.
62 v3d_set_transform_feedback_outputs(struct v3d_uncompiled_shader
*so
,
63 const struct pipe_stream_output_info
*stream_output
)
65 if (!stream_output
->num_outputs
)
68 struct v3d_varying_slot slots
[PIPE_MAX_SO_OUTPUTS
* 4];
71 for (int buffer
= 0; buffer
< PIPE_MAX_SO_BUFFERS
; buffer
++) {
72 uint32_t buffer_offset
= 0;
73 uint32_t vpm_start
= slot_count
;
75 for (int i
= 0; i
< stream_output
->num_outputs
; i
++) {
76 const struct pipe_stream_output
*output
=
77 &stream_output
->output
[i
];
79 if (output
->output_buffer
!= buffer
)
82 /* We assume that the SO outputs appear in increasing
83 * order in the buffer.
85 assert(output
->dst_offset
>= buffer_offset
);
87 /* Pad any undefined slots in the output */
88 for (int j
= buffer_offset
; j
< output
->dst_offset
; j
++) {
90 v3d_slot_from_slot_and_component(VARYING_SLOT_POS
, 0);
95 /* Set the coordinate shader up to output the
96 * components of this varying.
98 for (int j
= 0; j
< output
->num_components
; j
++) {
99 gl_varying_slot slot
=
100 v3d_get_slot_for_driver_location(so
->base
.ir
.nir
, output
->register_index
);
103 v3d_slot_from_slot_and_component(slot
,
104 output
->start_component
+ j
);
110 uint32_t vpm_size
= slot_count
- vpm_start
;
114 uint32_t vpm_start_offset
= vpm_start
+ 6;
117 uint32_t write_size
= MIN2(vpm_size
, 1 << 4);
119 struct V3D33_TRANSFORM_FEEDBACK_OUTPUT_DATA_SPEC unpacked
= {
120 /* We need the offset from the coordinate shader's VPM
121 * output block, which has the [X, Y, Z, W, Xs, Ys]
122 * values at the start.
124 .first_shaded_vertex_value_to_output
= vpm_start_offset
,
125 .number_of_consecutive_vertex_values_to_output_as_32_bit_values
= write_size
,
126 .output_buffer_to_write_to
= buffer
,
130 assert(unpacked
.first_shaded_vertex_value_to_output
!= 8 ||
131 so
->num_tf_specs
!= 0);
133 assert(so
->num_tf_specs
!= ARRAY_SIZE(so
->tf_specs
));
134 V3D33_TRANSFORM_FEEDBACK_OUTPUT_DATA_SPEC_pack(NULL
,
135 (void *)&so
->tf_specs
[so
->num_tf_specs
],
138 /* If point size is being written by the shader, then
139 * all the VPM start offsets are shifted up by one.
140 * We won't know that until the variant is compiled,
143 unpacked
.first_shaded_vertex_value_to_output
++;
146 assert(unpacked
.first_shaded_vertex_value_to_output
!= 8 ||
147 so
->num_tf_specs
!= 0);
149 V3D33_TRANSFORM_FEEDBACK_OUTPUT_DATA_SPEC_pack(NULL
,
150 (void *)&so
->tf_specs_psiz
[so
->num_tf_specs
],
153 vpm_start_offset
+= write_size
;
154 vpm_size
-= write_size
;
156 so
->base
.stream_output
.stride
[buffer
] =
157 stream_output
->stride
[buffer
];
160 so
->num_tf_outputs
= slot_count
;
161 so
->tf_outputs
= ralloc_array(so
->base
.ir
.nir
, struct v3d_varying_slot
,
163 memcpy(so
->tf_outputs
, slots
, sizeof(*slots
) * slot_count
);
167 type_size(const struct glsl_type
*type
)
169 return glsl_count_attribute_slots(type
, false);
173 uniforms_type_size(const struct glsl_type
*type
)
175 return st_glsl_storage_type_size(type
, false);
179 v3d_shader_state_create(struct pipe_context
*pctx
,
180 const struct pipe_shader_state
*cso
)
182 struct v3d_context
*v3d
= v3d_context(pctx
);
183 struct v3d_uncompiled_shader
*so
= CALLOC_STRUCT(v3d_uncompiled_shader
);
187 so
->program_id
= v3d
->next_uncompiled_program_id
++;
191 if (cso
->type
== PIPE_SHADER_IR_NIR
) {
192 /* The backend takes ownership of the NIR shader on state
197 NIR_PASS_V(s
, nir_lower_io
, nir_var_uniform
,
199 (nir_lower_io_options
)0);
201 assert(cso
->type
== PIPE_SHADER_IR_TGSI
);
203 if (V3D_DEBUG
& V3D_DEBUG_TGSI
) {
204 fprintf(stderr
, "prog %d TGSI:\n",
206 tgsi_dump(cso
->tokens
, 0);
207 fprintf(stderr
, "\n");
209 s
= tgsi_to_nir(cso
->tokens
, &v3d_nir_options
);
214 nir_variable_mode lower_mode
= nir_var_all
& ~nir_var_uniform
;
215 if (s
->info
.stage
== MESA_SHADER_VERTEX
)
216 lower_mode
&= ~(nir_var_shader_in
| nir_var_shader_out
);
217 NIR_PASS_V(s
, nir_lower_io
, lower_mode
,
219 (nir_lower_io_options
)0);
221 NIR_PASS_V(s
, nir_opt_global_to_local
);
222 NIR_PASS_V(s
, nir_lower_regs_to_ssa
);
223 NIR_PASS_V(s
, nir_normalize_cubemap_coords
);
225 NIR_PASS_V(s
, nir_lower_load_const_to_scalar
);
229 NIR_PASS_V(s
, nir_remove_dead_variables
, nir_var_local
);
231 /* Garbage collect dead instructions */
234 so
->base
.type
= PIPE_SHADER_IR_NIR
;
237 v3d_set_transform_feedback_outputs(so
, &cso
->stream_output
);
239 if (V3D_DEBUG
& (V3D_DEBUG_NIR
|
240 v3d_debug_flag_for_shader_stage(s
->info
.stage
))) {
241 fprintf(stderr
, "%s prog %d NIR:\n",
242 gl_shader_stage_name(s
->info
.stage
),
244 nir_print_shader(s
, stderr
);
245 fprintf(stderr
, "\n");
251 static struct v3d_compiled_shader
*
252 v3d_get_compiled_shader(struct v3d_context
*v3d
, struct v3d_key
*key
)
254 struct v3d_uncompiled_shader
*shader_state
= key
->shader_state
;
255 nir_shader
*s
= shader_state
->base
.ir
.nir
;
257 struct hash_table
*ht
;
259 if (s
->info
.stage
== MESA_SHADER_FRAGMENT
) {
261 key_size
= sizeof(struct v3d_fs_key
);
264 key_size
= sizeof(struct v3d_vs_key
);
267 struct hash_entry
*entry
= _mesa_hash_table_search(ht
, key
);
271 struct v3d_compiled_shader
*shader
=
272 rzalloc(NULL
, struct v3d_compiled_shader
);
274 int program_id
= shader_state
->program_id
;
276 p_atomic_inc_return(&shader_state
->compiled_variant_count
);
278 uint32_t shader_size
;
280 switch (s
->info
.stage
) {
281 case MESA_SHADER_VERTEX
:
282 shader
->prog_data
.vs
= rzalloc(shader
, struct v3d_vs_prog_data
);
284 qpu_insts
= v3d_compile_vs(v3d
->screen
->compiler
,
285 (struct v3d_vs_key
*)key
,
286 shader
->prog_data
.vs
, s
,
287 program_id
, variant_id
,
290 case MESA_SHADER_FRAGMENT
:
291 shader
->prog_data
.fs
= rzalloc(shader
, struct v3d_fs_prog_data
);
293 qpu_insts
= v3d_compile_fs(v3d
->screen
->compiler
,
294 (struct v3d_fs_key
*)key
,
295 shader
->prog_data
.fs
, s
,
296 program_id
, variant_id
,
300 unreachable("bad stage");
303 v3d_set_shader_uniform_dirty_flags(shader
);
305 u_upload_data(v3d
->state_uploader
, 0, shader_size
, 8,
306 qpu_insts
, &shader
->offset
, &shader
->resource
);
310 struct v3d_key
*dup_key
;
311 dup_key
= ralloc_size(shader
, key_size
);
312 memcpy(dup_key
, key
, key_size
);
313 _mesa_hash_table_insert(ht
, dup_key
, shader
);
315 if (shader
->prog_data
.base
->spill_size
>
316 v3d
->prog
.spill_size_per_thread
) {
317 /* Max 4 QPUs per slice, 3 slices per core. We only do single
318 * core so far. This overallocates memory on smaller cores.
320 int total_spill_size
=
321 4 * 3 * shader
->prog_data
.base
->spill_size
;
323 v3d_bo_unreference(&v3d
->prog
.spill_bo
);
324 v3d
->prog
.spill_bo
= v3d_bo_alloc(v3d
->screen
,
325 total_spill_size
, "spill");
326 v3d
->prog
.spill_size_per_thread
=
327 shader
->prog_data
.base
->spill_size
;
334 v3d_free_compiled_shader(struct v3d_compiled_shader
*shader
)
336 pipe_resource_reference(&shader
->resource
, NULL
);
341 v3d_setup_shared_key(struct v3d_context
*v3d
, struct v3d_key
*key
,
342 struct v3d_texture_stateobj
*texstate
)
344 const struct v3d_device_info
*devinfo
= &v3d
->screen
->devinfo
;
346 for (int i
= 0; i
< texstate
->num_textures
; i
++) {
347 struct pipe_sampler_view
*sampler
= texstate
->textures
[i
];
348 struct v3d_sampler_view
*v3d_sampler
= v3d_sampler_view(sampler
);
349 struct pipe_sampler_state
*sampler_state
=
350 texstate
->samplers
[i
];
355 key
->tex
[i
].return_size
=
356 v3d_get_tex_return_size(devinfo
,
358 sampler_state
->compare_mode
);
360 /* For 16-bit, we set up the sampler to always return 2
361 * channels (meaning no recompiles for most statechanges),
362 * while for 32 we actually scale the returns with channels.
364 if (key
->tex
[i
].return_size
== 16) {
365 key
->tex
[i
].return_channels
= 2;
366 } else if (devinfo
->ver
> 40) {
367 key
->tex
[i
].return_channels
= 4;
369 key
->tex
[i
].return_channels
=
370 v3d_get_tex_return_channels(devinfo
,
374 if (key
->tex
[i
].return_size
== 32 && devinfo
->ver
< 40) {
375 memcpy(key
->tex
[i
].swizzle
,
376 v3d_sampler
->swizzle
,
377 sizeof(v3d_sampler
->swizzle
));
379 /* For 16-bit returns, we let the sampler state handle
382 key
->tex
[i
].swizzle
[0] = PIPE_SWIZZLE_X
;
383 key
->tex
[i
].swizzle
[1] = PIPE_SWIZZLE_Y
;
384 key
->tex
[i
].swizzle
[2] = PIPE_SWIZZLE_Z
;
385 key
->tex
[i
].swizzle
[3] = PIPE_SWIZZLE_W
;
389 key
->tex
[i
].clamp_s
=
390 sampler_state
->wrap_s
== PIPE_TEX_WRAP_CLAMP
;
391 key
->tex
[i
].clamp_t
=
392 sampler_state
->wrap_t
== PIPE_TEX_WRAP_CLAMP
;
393 key
->tex
[i
].clamp_r
=
394 sampler_state
->wrap_r
== PIPE_TEX_WRAP_CLAMP
;
398 key
->ucp_enables
= v3d
->rasterizer
->base
.clip_plane_enable
;
402 v3d_update_compiled_fs(struct v3d_context
*v3d
, uint8_t prim_mode
)
404 struct v3d_job
*job
= v3d
->job
;
405 struct v3d_fs_key local_key
;
406 struct v3d_fs_key
*key
= &local_key
;
408 if (!(v3d
->dirty
& (VC5_DIRTY_PRIM_MODE
|
410 VC5_DIRTY_FRAMEBUFFER
|
412 VC5_DIRTY_RASTERIZER
|
413 VC5_DIRTY_SAMPLE_STATE
|
415 VC5_DIRTY_UNCOMPILED_FS
))) {
419 memset(key
, 0, sizeof(*key
));
420 v3d_setup_shared_key(v3d
, &key
->base
, &v3d
->tex
[PIPE_SHADER_FRAGMENT
]);
421 key
->base
.shader_state
= v3d
->prog
.bind_fs
;
422 key
->is_points
= (prim_mode
== PIPE_PRIM_POINTS
);
423 key
->is_lines
= (prim_mode
>= PIPE_PRIM_LINES
&&
424 prim_mode
<= PIPE_PRIM_LINE_STRIP
);
425 key
->clamp_color
= v3d
->rasterizer
->base
.clamp_fragment_color
;
426 if (v3d
->blend
->base
.logicop_enable
) {
427 key
->logicop_func
= v3d
->blend
->base
.logicop_func
;
429 key
->logicop_func
= PIPE_LOGICOP_COPY
;
432 key
->msaa
= v3d
->rasterizer
->base
.multisample
;
433 key
->sample_coverage
= (v3d
->rasterizer
->base
.multisample
&&
434 v3d
->sample_mask
!= (1 << VC5_MAX_SAMPLES
) - 1);
435 key
->sample_alpha_to_coverage
= v3d
->blend
->base
.alpha_to_coverage
;
436 key
->sample_alpha_to_one
= v3d
->blend
->base
.alpha_to_one
;
439 key
->depth_enabled
= (v3d
->zsa
->base
.depth
.enabled
||
440 v3d
->zsa
->base
.stencil
[0].enabled
);
441 if (v3d
->zsa
->base
.alpha
.enabled
) {
442 key
->alpha_test
= true;
443 key
->alpha_test_func
= v3d
->zsa
->base
.alpha
.func
;
446 /* gl_FragColor's propagation to however many bound color buffers
447 * there are means that the buffer count needs to be in the key.
449 key
->nr_cbufs
= v3d
->framebuffer
.nr_cbufs
;
450 key
->swap_color_rb
= v3d
->swap_color_rb
;
452 for (int i
= 0; i
< key
->nr_cbufs
; i
++) {
453 struct pipe_surface
*cbuf
= v3d
->framebuffer
.cbufs
[i
];
457 const struct util_format_description
*desc
=
458 util_format_description(cbuf
->format
);
460 if (desc
->channel
[0].type
== UTIL_FORMAT_TYPE_FLOAT
&&
461 desc
->channel
[0].size
== 32) {
462 key
->f32_color_rb
|= 1 << i
;
465 if (v3d
->prog
.bind_fs
->was_tgsi
) {
466 if (util_format_is_pure_uint(cbuf
->format
))
467 key
->uint_color_rb
|= 1 << i
;
468 else if (util_format_is_pure_sint(cbuf
->format
))
469 key
->int_color_rb
|= 1 << i
;
473 if (key
->is_points
) {
474 key
->point_sprite_mask
=
475 v3d
->rasterizer
->base
.sprite_coord_enable
;
476 key
->point_coord_upper_left
=
477 (v3d
->rasterizer
->base
.sprite_coord_mode
==
478 PIPE_SPRITE_COORD_UPPER_LEFT
);
481 key
->light_twoside
= v3d
->rasterizer
->base
.light_twoside
;
482 key
->shade_model_flat
= v3d
->rasterizer
->base
.flatshade
;
484 struct v3d_compiled_shader
*old_fs
= v3d
->prog
.fs
;
485 v3d
->prog
.fs
= v3d_get_compiled_shader(v3d
, &key
->base
);
486 if (v3d
->prog
.fs
== old_fs
)
489 v3d
->dirty
|= VC5_DIRTY_COMPILED_FS
;
492 if (v3d
->prog
.fs
->prog_data
.fs
->flat_shade_flags
!=
493 old_fs
->prog_data
.fs
->flat_shade_flags
) {
494 v3d
->dirty
|= VC5_DIRTY_FLAT_SHADE_FLAGS
;
497 if (v3d
->prog
.fs
->prog_data
.fs
->noperspective_flags
!=
498 old_fs
->prog_data
.fs
->noperspective_flags
) {
499 v3d
->dirty
|= VC5_DIRTY_NOPERSPECTIVE_FLAGS
;
502 if (v3d
->prog
.fs
->prog_data
.fs
->centroid_flags
!=
503 old_fs
->prog_data
.fs
->centroid_flags
) {
504 v3d
->dirty
|= VC5_DIRTY_CENTROID_FLAGS
;
508 if (old_fs
&& memcmp(v3d
->prog
.fs
->prog_data
.fs
->input_slots
,
509 old_fs
->prog_data
.fs
->input_slots
,
510 sizeof(v3d
->prog
.fs
->prog_data
.fs
->input_slots
))) {
511 v3d
->dirty
|= VC5_DIRTY_FS_INPUTS
;
516 v3d_update_compiled_vs(struct v3d_context
*v3d
, uint8_t prim_mode
)
518 struct v3d_vs_key local_key
;
519 struct v3d_vs_key
*key
= &local_key
;
521 if (!(v3d
->dirty
& (VC5_DIRTY_PRIM_MODE
|
522 VC5_DIRTY_RASTERIZER
|
525 VC5_DIRTY_UNCOMPILED_VS
|
526 VC5_DIRTY_FS_INPUTS
))) {
530 memset(key
, 0, sizeof(*key
));
531 v3d_setup_shared_key(v3d
, &key
->base
, &v3d
->tex
[PIPE_SHADER_VERTEX
]);
532 key
->base
.shader_state
= v3d
->prog
.bind_vs
;
533 key
->num_fs_inputs
= v3d
->prog
.fs
->prog_data
.fs
->base
.num_inputs
;
534 STATIC_ASSERT(sizeof(key
->fs_inputs
) ==
535 sizeof(v3d
->prog
.fs
->prog_data
.fs
->input_slots
));
536 memcpy(key
->fs_inputs
, v3d
->prog
.fs
->prog_data
.fs
->input_slots
,
537 sizeof(key
->fs_inputs
));
538 key
->clamp_color
= v3d
->rasterizer
->base
.clamp_vertex_color
;
540 key
->per_vertex_point_size
=
541 (prim_mode
== PIPE_PRIM_POINTS
&&
542 v3d
->rasterizer
->base
.point_size_per_vertex
);
544 struct v3d_compiled_shader
*vs
=
545 v3d_get_compiled_shader(v3d
, &key
->base
);
546 if (vs
!= v3d
->prog
.vs
) {
548 v3d
->dirty
|= VC5_DIRTY_COMPILED_VS
;
551 key
->is_coord
= true;
552 /* Coord shaders only output varyings used by transform feedback. */
553 struct v3d_uncompiled_shader
*shader_state
= key
->base
.shader_state
;
554 memcpy(key
->fs_inputs
, shader_state
->tf_outputs
,
555 sizeof(*key
->fs_inputs
) * shader_state
->num_tf_outputs
);
556 if (shader_state
->num_tf_outputs
< key
->num_fs_inputs
) {
557 memset(&key
->fs_inputs
[shader_state
->num_tf_outputs
],
559 sizeof(*key
->fs_inputs
) * (key
->num_fs_inputs
-
560 shader_state
->num_tf_outputs
));
562 key
->num_fs_inputs
= shader_state
->num_tf_outputs
;
564 struct v3d_compiled_shader
*cs
=
565 v3d_get_compiled_shader(v3d
, &key
->base
);
566 if (cs
!= v3d
->prog
.cs
) {
568 v3d
->dirty
|= VC5_DIRTY_COMPILED_CS
;
573 v3d_update_compiled_shaders(struct v3d_context
*v3d
, uint8_t prim_mode
)
575 v3d_update_compiled_fs(v3d
, prim_mode
);
576 v3d_update_compiled_vs(v3d
, prim_mode
);
580 fs_cache_hash(const void *key
)
582 return _mesa_hash_data(key
, sizeof(struct v3d_fs_key
));
586 vs_cache_hash(const void *key
)
588 return _mesa_hash_data(key
, sizeof(struct v3d_vs_key
));
592 fs_cache_compare(const void *key1
, const void *key2
)
594 return memcmp(key1
, key2
, sizeof(struct v3d_fs_key
)) == 0;
598 vs_cache_compare(const void *key1
, const void *key2
)
600 return memcmp(key1
, key2
, sizeof(struct v3d_vs_key
)) == 0;
604 delete_from_cache_if_matches(struct hash_table
*ht
,
605 struct v3d_compiled_shader
**last_compile
,
606 struct hash_entry
*entry
,
607 struct v3d_uncompiled_shader
*so
)
609 const struct v3d_key
*key
= entry
->key
;
611 if (key
->shader_state
== so
) {
612 struct v3d_compiled_shader
*shader
= entry
->data
;
613 _mesa_hash_table_remove(ht
, entry
);
615 if (shader
== *last_compile
)
616 *last_compile
= NULL
;
618 v3d_free_compiled_shader(shader
);
623 v3d_shader_state_delete(struct pipe_context
*pctx
, void *hwcso
)
625 struct v3d_context
*v3d
= v3d_context(pctx
);
626 struct v3d_uncompiled_shader
*so
= hwcso
;
628 hash_table_foreach(v3d
->fs_cache
, entry
) {
629 delete_from_cache_if_matches(v3d
->fs_cache
, &v3d
->prog
.fs
,
632 hash_table_foreach(v3d
->vs_cache
, entry
) {
633 delete_from_cache_if_matches(v3d
->vs_cache
, &v3d
->prog
.vs
,
637 ralloc_free(so
->base
.ir
.nir
);
642 v3d_fp_state_bind(struct pipe_context
*pctx
, void *hwcso
)
644 struct v3d_context
*v3d
= v3d_context(pctx
);
645 v3d
->prog
.bind_fs
= hwcso
;
646 v3d
->dirty
|= VC5_DIRTY_UNCOMPILED_FS
;
650 v3d_vp_state_bind(struct pipe_context
*pctx
, void *hwcso
)
652 struct v3d_context
*v3d
= v3d_context(pctx
);
653 v3d
->prog
.bind_vs
= hwcso
;
654 v3d
->dirty
|= VC5_DIRTY_UNCOMPILED_VS
;
658 v3d_program_init(struct pipe_context
*pctx
)
660 struct v3d_context
*v3d
= v3d_context(pctx
);
662 pctx
->create_vs_state
= v3d_shader_state_create
;
663 pctx
->delete_vs_state
= v3d_shader_state_delete
;
665 pctx
->create_fs_state
= v3d_shader_state_create
;
666 pctx
->delete_fs_state
= v3d_shader_state_delete
;
668 pctx
->bind_fs_state
= v3d_fp_state_bind
;
669 pctx
->bind_vs_state
= v3d_vp_state_bind
;
671 v3d
->fs_cache
= _mesa_hash_table_create(pctx
, fs_cache_hash
,
673 v3d
->vs_cache
= _mesa_hash_table_create(pctx
, vs_cache_hash
,
678 v3d_program_fini(struct pipe_context
*pctx
)
680 struct v3d_context
*v3d
= v3d_context(pctx
);
682 hash_table_foreach(v3d
->fs_cache
, entry
) {
683 struct v3d_compiled_shader
*shader
= entry
->data
;
684 v3d_free_compiled_shader(shader
);
685 _mesa_hash_table_remove(v3d
->fs_cache
, entry
);
688 hash_table_foreach(v3d
->vs_cache
, entry
) {
689 struct v3d_compiled_shader
*shader
= entry
->data
;
690 v3d_free_compiled_shader(shader
);
691 _mesa_hash_table_remove(v3d
->vs_cache
, entry
);
694 v3d_bo_unreference(&v3d
->prog
.spill_bo
);