iris: move key pop to state module

shader key population needs to read state
This commit is contained in:
Kenneth Graunke 2018-01-25 02:03:18 -08:00
parent 5864c9414a
commit bba13b1501
3 changed files with 87 additions and 40 deletions

View file

@ -27,6 +27,7 @@
#include "pipe/p_state.h"
#include "util/u_debug.h"
#include "intel/common/gen_debug.h"
#include "intel/compiler/brw_compiler.h"
#include "iris_batch.h"
#include "iris_screen.h"
@ -142,6 +143,7 @@ struct iris_context {
struct iris_sampler_state *samplers[MESA_SHADER_STAGES][IRIS_MAX_TEXTURE_SAMPLERS];
void (*destroy_state)(struct iris_context *ice);
void (*init_render_context)(struct iris_screen *screen,
struct iris_batch *batch,
struct pipe_debug_callback *dbg);
@ -152,7 +154,16 @@ struct iris_context {
void (*set_derived_program_state)(const struct gen_device_info *devinfo,
enum iris_program_cache_id cache_id,
struct iris_compiled_shader *shader);
void (*destroy_state)(struct iris_context *ice);
void (*populate_vs_key)(const struct iris_context *ice,
struct brw_vs_prog_key *key);
void (*populate_tcs_key)(const struct iris_context *ice,
struct brw_tcs_prog_key *key);
void (*populate_tes_key)(const struct iris_context *ice,
struct brw_tes_prog_key *key);
void (*populate_gs_key)(const struct iris_context *ice,
struct brw_gs_prog_key *key);
void (*populate_fs_key)(const struct iris_context *ice,
struct brw_wm_prog_key *key);
} state;
};
@ -175,10 +186,17 @@ void iris_init_resource_functions(struct pipe_context *ctx);
void iris_init_query_functions(struct pipe_context *ctx);
void iris_update_compiled_shaders(struct iris_context *ice);
/* iris_draw.c */
void iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info);
/* iris_state.c */
void gen9_init_state(struct iris_context *ice);
void gen10_init_state(struct iris_context *ice);
/* iris_program_cache.c */
void iris_init_program_cache(struct iris_context *ice);
void iris_destroy_program_cache(struct iris_context *ice);
void iris_print_program_cache(struct iris_context *ice);

View file

@ -239,17 +239,11 @@ iris_compile_vs(struct iris_context *ice,
return true;
}
static void
iris_populate_vs_key(struct iris_context *ice, struct brw_vs_prog_key *key)
{
memset(key, 0, sizeof(*key));
}
static void
iris_update_compiled_vs(struct iris_context *ice)
{
struct brw_vs_prog_key key;
iris_populate_vs_key(ice, &key);
ice->state.populate_vs_key(ice, &key);
if (iris_bind_cached_shader(ice, IRIS_CACHE_VS, &key))
return;
@ -316,41 +310,11 @@ iris_compile_fs(struct iris_context *ice,
return true;
}
static void
iris_populate_fs_key(struct iris_context *ice, struct brw_wm_prog_key *key)
{
memset(key, 0, sizeof(*key));
/* XXX: dirty flags? */
struct pipe_framebuffer_state *fb = &ice->state.framebuffer;
//struct iris_depth_stencil_alpha_state *zsa = ice->state.framebuffer;
// XXX: can't access iris structs outside iris_state.c :(
// XXX: maybe just move these to iris_state.c, honestly...they're more
// about state than programs...
key->nr_color_regions = fb->nr_cbufs;
// key->force_dual_color_blend for unigine
#if 0
//key->replicate_alpha = fb->nr_cbufs > 1 && alpha test or alpha to coverage
if (cso_rast->multisample) {
key->persample_interp =
ctx->Multisample.SampleShading &&
(ctx->Multisample.MinSampleShadingValue *
_mesa_geometric_samples(ctx->DrawBuffer) > 1);
key->multisample_fbo = fb->samples > 1;
}
#endif
key->coherent_fb_fetch = true;
}
static void
iris_update_compiled_fs(struct iris_context *ice)
{
struct brw_wm_prog_key key;
iris_populate_fs_key(ice, &key);
ice->state.populate_fs_key(ice, &key);
if (iris_bind_cached_shader(ice, IRIS_CACHE_FS, &key))
return;

View file

@ -1364,6 +1364,65 @@ iris_bind_compute_state(struct pipe_context *ctx, void *state)
{
}
static void
iris_populate_vs_key(const struct iris_context *ice,
struct brw_vs_prog_key *key)
{
memset(key, 0, sizeof(*key));
}
static void
iris_populate_tcs_key(const struct iris_context *ice,
struct brw_tcs_prog_key *key)
{
memset(key, 0, sizeof(*key));
}
static void
iris_populate_tes_key(const struct iris_context *ice,
struct brw_tes_prog_key *key)
{
memset(key, 0, sizeof(*key));
}
static void
iris_populate_gs_key(const struct iris_context *ice,
struct brw_gs_prog_key *key)
{
memset(key, 0, sizeof(*key));
}
static void
iris_populate_fs_key(const struct iris_context *ice,
struct brw_wm_prog_key *key)
{
memset(key, 0, sizeof(*key));
/* XXX: dirty flags? */
struct pipe_framebuffer_state *fb = &ice->state.framebuffer;
//struct iris_depth_stencil_alpha_state *zsa = ice->state.framebuffer;
// XXX: can't access iris structs outside iris_state.c :(
// XXX: maybe just move these to iris_state.c, honestly...they're more
// about state than programs...
key->nr_color_regions = fb->nr_cbufs;
// key->force_dual_color_blend for unigine
#if 0
//key->replicate_alpha = fb->nr_cbufs > 1 && alpha test or alpha to coverage
if (cso_rast->multisample) {
key->persample_interp =
ctx->Multisample.SampleShading &&
(ctx->Multisample.MinSampleShadingValue *
_mesa_geometric_samples(ctx->DrawBuffer) > 1);
key->multisample_fbo = fb->samples > 1;
}
#endif
key->coherent_fb_fetch = true;
}
//pkt.SamplerCount = \
//DIV_ROUND_UP(CLAMP(stage_state->sampler_count, 0, 16), 4); \
//pkt.PerThreadScratchSpace = prog_data->total_scratch == 0 ? 0 : \
@ -2014,11 +2073,17 @@ genX(init_state)(struct iris_context *ice)
ctx->stream_output_target_destroy = iris_stream_output_target_destroy;
ctx->set_stream_output_targets = iris_set_stream_output_targets;
ice->state.destroy_state = iris_destroy_state;
ice->state.init_render_context = iris_init_render_context;
ice->state.upload_render_state = iris_upload_render_state;
ice->state.derived_program_state_size = iris_derived_program_state_size;
ice->state.set_derived_program_state = iris_set_derived_program_state;
ice->state.destroy_state = iris_destroy_state;
ice->state.populate_vs_key = iris_populate_vs_key;
ice->state.populate_tcs_key = iris_populate_tcs_key;
ice->state.populate_tes_key = iris_populate_tes_key;
ice->state.populate_gs_key = iris_populate_gs_key;
ice->state.populate_fs_key = iris_populate_fs_key;
ice->state.dirty = ~0ull;
}