diff options
author | Eric Anholt <[email protected]> | 2018-12-04 13:48:10 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-12-07 16:48:23 -0800 |
commit | 504d06e4c1c5664c1e208179a43adbbd27fd4522 (patch) | |
tree | d67d493896a530c379508477abc1e4d74f057170 /src | |
parent | d1965344ac26e250f696ff15f6dff8aacbd1d6db (diff) |
v3d: Make an array for frag/vert texture state in the context.
This simplifies a bunch of our texture handling, while introducing the
slots necessary for adding new shader stages.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/v3d/v3d_blit.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_context.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_program.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_uniforms.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_draw.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_emit.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_state.c | 22 |
7 files changed, 21 insertions, 42 deletions
diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index f2ded8bbf72..25f4c61c62d 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -184,10 +184,11 @@ v3d_blitter_save(struct v3d_context *v3d) util_blitter_save_sample_mask(v3d->blitter, v3d->sample_mask); util_blitter_save_framebuffer(v3d->blitter, &v3d->framebuffer); util_blitter_save_fragment_sampler_states(v3d->blitter, - v3d->fragtex.num_samplers, - (void **)v3d->fragtex.samplers); + v3d->tex[PIPE_SHADER_FRAGMENT].num_samplers, + (void **)v3d->tex[PIPE_SHADER_FRAGMENT].samplers); util_blitter_save_fragment_sampler_views(v3d->blitter, - v3d->fragtex.num_textures, v3d->fragtex.textures); + v3d->tex[PIPE_SHADER_FRAGMENT].num_textures, + v3d->tex[PIPE_SHADER_FRAGMENT].textures); util_blitter_save_so_targets(v3d->blitter, v3d->streamout.num_targets, v3d->streamout.targets); } diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 6ffe09a9c1a..d62dd229ef2 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -386,8 +386,6 @@ struct v3d_context { struct v3d_rasterizer_state *rasterizer; struct v3d_depth_stencil_alpha_state *zsa; - struct v3d_texture_stateobj verttex, fragtex; - struct v3d_program_stateobj prog; struct v3d_vertex_stateobj *vtx; @@ -424,6 +422,7 @@ struct v3d_context { struct pipe_clip_state clip; struct pipe_viewport_state viewport; struct v3d_constbuf_stateobj constbuf[PIPE_SHADER_TYPES]; + struct v3d_texture_stateobj tex[PIPE_SHADER_TYPES]; struct v3d_vertexbuf_stateobj vertexbuf; struct v3d_streamout_stateobj streamout; struct v3d_bo *current_oq; @@ -501,8 +500,7 @@ v3d_ioctl(int fd, unsigned long request, void *arg) void v3d_set_shader_uniform_dirty_flags(struct v3d_compiled_shader *shader); struct v3d_cl_reloc v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, - struct v3d_constbuf_stateobj *cb, - struct v3d_texture_stateobj *texstate); + enum pipe_shader_type stage); void v3d_flush(struct pipe_context *pctx); void v3d_job_init(struct v3d_context *v3d); diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c index 25b346fd11b..6c9d5c461ab 100644 --- a/src/gallium/drivers/v3d/v3d_program.c +++ b/src/gallium/drivers/v3d/v3d_program.c @@ -419,7 +419,7 @@ v3d_update_compiled_fs(struct v3d_context *v3d, uint8_t prim_mode) } memset(key, 0, sizeof(*key)); - v3d_setup_shared_key(v3d, &key->base, &v3d->fragtex); + v3d_setup_shared_key(v3d, &key->base, &v3d->tex[PIPE_SHADER_FRAGMENT]); key->base.shader_state = v3d->prog.bind_fs; key->is_points = (prim_mode == PIPE_PRIM_POINTS); key->is_lines = (prim_mode >= PIPE_PRIM_LINES && @@ -530,7 +530,7 @@ v3d_update_compiled_vs(struct v3d_context *v3d, uint8_t prim_mode) } memset(key, 0, sizeof(*key)); - v3d_setup_shared_key(v3d, &key->base, &v3d->verttex); + v3d_setup_shared_key(v3d, &key->base, &v3d->tex[PIPE_SHADER_VERTEX]); key->base.shader_state = v3d->prog.bind_vs; key->num_fs_inputs = v3d->prog.fs->prog_data.fs->base.num_inputs; STATIC_ASSERT(sizeof(key->fs_inputs) == diff --git a/src/gallium/drivers/v3d/v3d_uniforms.c b/src/gallium/drivers/v3d/v3d_uniforms.c index 6f0ef915535..d2e3e710237 100644 --- a/src/gallium/drivers/v3d/v3d_uniforms.c +++ b/src/gallium/drivers/v3d/v3d_uniforms.c @@ -259,9 +259,10 @@ write_tmu_p1(struct v3d_job *job, struct v3d_cl_reloc v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, - struct v3d_constbuf_stateobj *cb, - struct v3d_texture_stateobj *texstate) + enum pipe_shader_type stage) { + struct v3d_constbuf_stateobj *cb = &v3d->constbuf[stage]; + struct v3d_texture_stateobj *texstate = &v3d->tex[stage]; struct v3d_uniform_list *uinfo = &shader->prog_data.base->uniforms; struct v3d_job *job = v3d->job; const uint32_t *gallium_uniforms = cb->cb[0].user_buffer; diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 051907f1250..519aa9157d5 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -146,16 +146,13 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d, /* Upload the uniforms to the indirect CL first */ struct v3d_cl_reloc fs_uniforms = v3d_write_uniforms(v3d, v3d->prog.fs, - &v3d->constbuf[PIPE_SHADER_FRAGMENT], - &v3d->fragtex); + PIPE_SHADER_FRAGMENT); struct v3d_cl_reloc vs_uniforms = v3d_write_uniforms(v3d, v3d->prog.vs, - &v3d->constbuf[PIPE_SHADER_VERTEX], - &v3d->verttex); + PIPE_SHADER_VERTEX); struct v3d_cl_reloc cs_uniforms = v3d_write_uniforms(v3d, v3d->prog.cs, - &v3d->constbuf[PIPE_SHADER_VERTEX], - &v3d->verttex); + PIPE_SHADER_VERTEX); /* See GFXH-930 workaround below */ uint32_t num_elements_to_emit = MAX2(vtx->num_elements, 1); @@ -438,8 +435,8 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) /* Before setting up the draw, flush anything writing to the textures * that we read from. */ - v3d_predraw_check_textures(pctx, &v3d->verttex); - v3d_predraw_check_textures(pctx, &v3d->fragtex); + for (int s = 0; s < PIPE_SHADER_TYPES; s++) + v3d_predraw_check_textures(pctx, &v3d->tex[s]); struct v3d_job *job = v3d_get_job_for_fbo(v3d); @@ -451,7 +448,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) * on the last submitted render, rather than tracking the last * rendering to each texture's BO. */ - if (v3d->verttex.num_textures) { + if (v3d->tex[PIPE_SHADER_VERTEX].num_textures) { perf_debug("Blocking binner on last render " "due to vertex texturing.\n"); job->submit.in_sync_bcl = v3d->out_sync; diff --git a/src/gallium/drivers/v3d/v3dx_emit.c b/src/gallium/drivers/v3d/v3dx_emit.c index 0d14bcf4dde..adaf5f6c139 100644 --- a/src/gallium/drivers/v3d/v3dx_emit.c +++ b/src/gallium/drivers/v3d/v3dx_emit.c @@ -653,10 +653,10 @@ v3dX(emit_state)(struct pipe_context *pctx) * the view, so we merge them together at draw time. */ if (v3d->dirty & VC5_DIRTY_FRAGTEX) - emit_textures(v3d, &v3d->fragtex); + emit_textures(v3d, &v3d->tex[PIPE_SHADER_FRAGMENT]); if (v3d->dirty & VC5_DIRTY_VERTTEX) - emit_textures(v3d, &v3d->verttex); + emit_textures(v3d, &v3d->tex[PIPE_SHADER_VERTEX]); #endif if (v3d->dirty & VC5_DIRTY_FLAT_SHADE_FLAGS) { diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c index 75c81f099dd..0d1a74091d5 100644 --- a/src/gallium/drivers/v3d/v3dx_state.c +++ b/src/gallium/drivers/v3d/v3dx_state.c @@ -502,24 +502,6 @@ v3d_set_framebuffer_state(struct pipe_context *pctx, v3d->dirty |= VC5_DIRTY_FRAMEBUFFER; } -static struct v3d_texture_stateobj * -v3d_get_stage_tex(struct v3d_context *v3d, enum pipe_shader_type shader) -{ - switch (shader) { - case PIPE_SHADER_FRAGMENT: - v3d->dirty |= VC5_DIRTY_FRAGTEX; - return &v3d->fragtex; - break; - case PIPE_SHADER_VERTEX: - v3d->dirty |= VC5_DIRTY_VERTTEX; - return &v3d->verttex; - break; - default: - fprintf(stderr, "Unknown shader target %d\n", shader); - abort(); - } -} - static uint32_t translate_wrap(uint32_t pipe_wrap, bool using_nearest) { switch (pipe_wrap) { @@ -644,7 +626,7 @@ v3d_sampler_states_bind(struct pipe_context *pctx, unsigned nr, void **hwcso) { struct v3d_context *v3d = v3d_context(pctx); - struct v3d_texture_stateobj *stage_tex = v3d_get_stage_tex(v3d, shader); + struct v3d_texture_stateobj *stage_tex = &v3d->tex[shader]; assert(start == 0); unsigned i; @@ -876,7 +858,7 @@ v3d_set_sampler_views(struct pipe_context *pctx, struct pipe_sampler_view **views) { struct v3d_context *v3d = v3d_context(pctx); - struct v3d_texture_stateobj *stage_tex = v3d_get_stage_tex(v3d, shader); + struct v3d_texture_stateobj *stage_tex = &v3d->tex[shader]; unsigned i; unsigned new_nr = 0; |