anv: Store prog data in pipeline cache stream

We have to keep it there for the cache to work, so let's not have an
extra copy in struct anv_pipeline too.
This commit is contained in:
Kristian Høgsberg Kristensen
2016-03-04 08:15:16 -08:00
parent 37c5e70253
commit 2b29342fae
11 changed files with 171 additions and 123 deletions

View File

@@ -757,7 +757,7 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
} }
if (stage == MESA_SHADER_COMPUTE && if (stage == MESA_SHADER_COMPUTE &&
cmd_buffer->state.compute_pipeline->cs_prog_data.uses_num_work_groups) { get_cs_prog_data(cmd_buffer->state.compute_pipeline)->uses_num_work_groups) {
struct anv_bo *bo = cmd_buffer->state.num_workgroups_bo; struct anv_bo *bo = cmd_buffer->state.num_workgroups_bo;
uint32_t bo_offset = cmd_buffer->state.num_workgroups_offset; uint32_t bo_offset = cmd_buffer->state.num_workgroups_offset;
@@ -996,7 +996,7 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer,
{ {
struct anv_push_constants *data = struct anv_push_constants *data =
cmd_buffer->state.push_constants[stage]; cmd_buffer->state.push_constants[stage];
struct brw_stage_prog_data *prog_data = const struct brw_stage_prog_data *prog_data =
cmd_buffer->state.pipeline->prog_data[stage]; cmd_buffer->state.pipeline->prog_data[stage];
/* If we don't actually have any push constants, bail. */ /* If we don't actually have any push constants, bail. */
@@ -1027,7 +1027,7 @@ anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer *cmd_buffer)
struct anv_push_constants *data = struct anv_push_constants *data =
cmd_buffer->state.push_constants[MESA_SHADER_COMPUTE]; cmd_buffer->state.push_constants[MESA_SHADER_COMPUTE];
struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
const struct brw_cs_prog_data *cs_prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
const struct brw_stage_prog_data *prog_data = &cs_prog_data->base; const struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
const unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8; const unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8;

View File

@@ -406,7 +406,7 @@ anv_pipeline_compile(struct anv_pipeline *pipeline,
static void static void
anv_pipeline_add_compiled_stage(struct anv_pipeline *pipeline, anv_pipeline_add_compiled_stage(struct anv_pipeline *pipeline,
gl_shader_stage stage, gl_shader_stage stage,
struct brw_stage_prog_data *prog_data) const struct brw_stage_prog_data *prog_data)
{ {
struct brw_device_info *devinfo = &pipeline->device->info; struct brw_device_info *devinfo = &pipeline->device->info;
uint32_t max_threads[] = { uint32_t max_threads[] = {
@@ -436,7 +436,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler; pipeline->device->instance->physicalDevice.compiler;
struct brw_vs_prog_data *prog_data = &pipeline->vs_prog_data; const struct brw_stage_prog_data *stage_prog_data;
struct brw_vs_prog_key key; struct brw_vs_prog_key key;
uint32_t kernel; uint32_t kernel;
unsigned char sha1[20], *hash; unsigned char sha1[20], *hash;
@@ -446,17 +446,17 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
if (module->size > 0) { if (module->size > 0) {
hash = sha1; hash = sha1;
anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info); anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info);
kernel = anv_pipeline_cache_search(cache, hash, prog_data); kernel = anv_pipeline_cache_search(cache, hash, &stage_prog_data);
} else { } else {
hash = NULL; hash = NULL;
} }
if (module->size == 0 || kernel == NO_KERNEL) { if (module->size == 0 || kernel == NO_KERNEL) {
memset(prog_data, 0, sizeof(*prog_data)); struct brw_vs_prog_data prog_data = { 0, };
nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint, nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
MESA_SHADER_VERTEX, spec_info, MESA_SHADER_VERTEX, spec_info,
&prog_data->base.base); &prog_data.base.base);
if (nir == NULL) if (nir == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -465,31 +465,36 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
if (module->nir == NULL) if (module->nir == NULL)
ralloc_steal(mem_ctx, nir); ralloc_steal(mem_ctx, nir);
prog_data->inputs_read = nir->info.inputs_read; prog_data.inputs_read = nir->info.inputs_read;
if (nir->info.outputs_written & (1ull << VARYING_SLOT_PSIZ)) if (nir->info.outputs_written & (1ull << VARYING_SLOT_PSIZ))
pipeline->writes_point_size = true; pipeline->writes_point_size = true;
brw_compute_vue_map(&pipeline->device->info, brw_compute_vue_map(&pipeline->device->info,
&prog_data->base.vue_map, &prog_data.base.vue_map,
nir->info.outputs_written, nir->info.outputs_written,
nir->info.separate_shader); nir->info.separate_shader);
unsigned code_size; unsigned code_size;
const unsigned *shader_code = const unsigned *shader_code =
brw_compile_vs(compiler, NULL, mem_ctx, &key, prog_data, nir, brw_compile_vs(compiler, NULL, mem_ctx, &key, &prog_data, nir,
NULL, false, -1, &code_size, NULL); NULL, false, -1, &code_size, NULL);
if (shader_code == NULL) { if (shader_code == NULL) {
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
} }
stage_prog_data = &prog_data.base.base;
kernel = anv_pipeline_cache_upload_kernel(cache, hash, kernel = anv_pipeline_cache_upload_kernel(cache, hash,
shader_code, code_size, shader_code, code_size,
prog_data, sizeof(*prog_data)); &stage_prog_data,
sizeof(prog_data));
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
} }
if (prog_data->base.dispatch_mode == DISPATCH_MODE_SIMD8) { const struct brw_vs_prog_data *vs_prog_data =
(const struct brw_vs_prog_data *) stage_prog_data;
if (vs_prog_data->base.dispatch_mode == DISPATCH_MODE_SIMD8) {
pipeline->vs_simd8 = kernel; pipeline->vs_simd8 = kernel;
pipeline->vs_vec4 = NO_KERNEL; pipeline->vs_vec4 = NO_KERNEL;
} else { } else {
@@ -498,7 +503,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
} }
anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_VERTEX, anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_VERTEX,
&prog_data->base.base); stage_prog_data);
return VK_SUCCESS; return VK_SUCCESS;
} }
@@ -513,7 +518,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler; pipeline->device->instance->physicalDevice.compiler;
struct brw_gs_prog_data *prog_data = &pipeline->gs_prog_data; const struct brw_stage_prog_data *stage_prog_data;
struct brw_gs_prog_key key; struct brw_gs_prog_key key;
uint32_t kernel; uint32_t kernel;
unsigned char sha1[20], *hash; unsigned char sha1[20], *hash;
@@ -523,17 +528,17 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
if (module->size > 0) { if (module->size > 0) {
hash = sha1; hash = sha1;
anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info); anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info);
kernel = anv_pipeline_cache_search(cache, hash, prog_data); kernel = anv_pipeline_cache_search(cache, hash, &stage_prog_data);
} else { } else {
hash = NULL; hash = NULL;
} }
if (module->size == 0 || kernel == NO_KERNEL) { if (module->size == 0 || kernel == NO_KERNEL) {
memset(prog_data, 0, sizeof(*prog_data)); struct brw_gs_prog_data prog_data = { 0, };
nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint, nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
MESA_SHADER_GEOMETRY, spec_info, MESA_SHADER_GEOMETRY, spec_info,
&prog_data->base.base); &prog_data.base.base);
if (nir == NULL) if (nir == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -546,13 +551,13 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
pipeline->writes_point_size = true; pipeline->writes_point_size = true;
brw_compute_vue_map(&pipeline->device->info, brw_compute_vue_map(&pipeline->device->info,
&prog_data->base.vue_map, &prog_data.base.vue_map,
nir->info.outputs_written, nir->info.outputs_written,
nir->info.separate_shader); nir->info.separate_shader);
unsigned code_size; unsigned code_size;
const unsigned *shader_code = const unsigned *shader_code =
brw_compile_gs(compiler, NULL, mem_ctx, &key, prog_data, nir, brw_compile_gs(compiler, NULL, mem_ctx, &key, &prog_data, nir,
NULL, -1, &code_size, NULL); NULL, -1, &code_size, NULL);
if (shader_code == NULL) { if (shader_code == NULL) {
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
@@ -560,9 +565,10 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
} }
/* TODO: SIMD8 GS */ /* TODO: SIMD8 GS */
stage_prog_data = &prog_data.base.base;
kernel = anv_pipeline_cache_upload_kernel(cache, hash, kernel = anv_pipeline_cache_upload_kernel(cache, hash,
shader_code, code_size, shader_code, code_size,
prog_data, sizeof(*prog_data)); &stage_prog_data, sizeof(prog_data));
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
} }
@@ -570,7 +576,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
pipeline->gs_kernel = kernel; pipeline->gs_kernel = kernel;
anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_GEOMETRY, anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_GEOMETRY,
&prog_data->base.base); stage_prog_data);
return VK_SUCCESS; return VK_SUCCESS;
} }
@@ -586,7 +592,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler; pipeline->device->instance->physicalDevice.compiler;
struct brw_wm_prog_data *prog_data = &pipeline->wm_prog_data; const struct brw_stage_prog_data *stage_prog_data;
struct brw_wm_prog_key key; struct brw_wm_prog_key key;
uint32_t kernel; uint32_t kernel;
unsigned char sha1[20], *hash; unsigned char sha1[20], *hash;
@@ -599,19 +605,19 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
if (module->size > 0) { if (module->size > 0) {
hash = sha1; hash = sha1;
anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info); anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info);
kernel = anv_pipeline_cache_search(cache, hash, prog_data); kernel = anv_pipeline_cache_search(cache, hash, &stage_prog_data);
} else { } else {
hash = NULL; hash = NULL;
} }
if (module->size == 0 || kernel == NO_KERNEL) { if (module->size == 0 || kernel == NO_KERNEL) {
memset(prog_data, 0, sizeof(*prog_data)); struct brw_wm_prog_data prog_data = { 0, };
prog_data->binding_table.render_target_start = 0; prog_data.binding_table.render_target_start = 0;
nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint, nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
MESA_SHADER_FRAGMENT, spec_info, MESA_SHADER_FRAGMENT, spec_info,
&prog_data->base); &prog_data.base);
if (nir == NULL) if (nir == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -635,27 +641,31 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
unsigned code_size; unsigned code_size;
const unsigned *shader_code = const unsigned *shader_code =
brw_compile_fs(compiler, NULL, mem_ctx, &key, prog_data, nir, brw_compile_fs(compiler, NULL, mem_ctx, &key, &prog_data, nir,
NULL, -1, -1, pipeline->use_repclear, &code_size, NULL); NULL, -1, -1, pipeline->use_repclear, &code_size, NULL);
if (shader_code == NULL) { if (shader_code == NULL) {
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
} }
stage_prog_data = &prog_data.base;
kernel = anv_pipeline_cache_upload_kernel(cache, hash, kernel = anv_pipeline_cache_upload_kernel(cache, hash,
shader_code, code_size, shader_code, code_size,
prog_data, sizeof(*prog_data)); &stage_prog_data, sizeof(prog_data));
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
} }
if (prog_data->no_8) const struct brw_wm_prog_data *wm_prog_data =
(const struct brw_wm_prog_data *) stage_prog_data;
if (wm_prog_data->no_8)
pipeline->ps_simd8 = NO_KERNEL; pipeline->ps_simd8 = NO_KERNEL;
else else
pipeline->ps_simd8 = kernel; pipeline->ps_simd8 = kernel;
if (prog_data->no_8 || prog_data->prog_offset_16) { if (wm_prog_data->no_8 || wm_prog_data->prog_offset_16) {
pipeline->ps_simd16 = kernel + prog_data->prog_offset_16; pipeline->ps_simd16 = kernel + wm_prog_data->prog_offset_16;
} else { } else {
pipeline->ps_simd16 = NO_KERNEL; pipeline->ps_simd16 = NO_KERNEL;
} }
@@ -664,18 +674,18 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
pipeline->ps_grf_start2 = 0; pipeline->ps_grf_start2 = 0;
if (pipeline->ps_simd8 != NO_KERNEL) { if (pipeline->ps_simd8 != NO_KERNEL) {
pipeline->ps_ksp0 = pipeline->ps_simd8; pipeline->ps_ksp0 = pipeline->ps_simd8;
pipeline->ps_grf_start0 = prog_data->base.dispatch_grf_start_reg; pipeline->ps_grf_start0 = wm_prog_data->base.dispatch_grf_start_reg;
if (pipeline->ps_simd16 != NO_KERNEL) { if (pipeline->ps_simd16 != NO_KERNEL) {
pipeline->ps_ksp2 = pipeline->ps_simd16; pipeline->ps_ksp2 = pipeline->ps_simd16;
pipeline->ps_grf_start2 = prog_data->dispatch_grf_start_reg_16; pipeline->ps_grf_start2 = wm_prog_data->dispatch_grf_start_reg_16;
} }
} else if (pipeline->ps_simd16 != NO_KERNEL) { } else if (pipeline->ps_simd16 != NO_KERNEL) {
pipeline->ps_ksp0 = pipeline->ps_simd16; pipeline->ps_ksp0 = pipeline->ps_simd16;
pipeline->ps_grf_start0 = prog_data->dispatch_grf_start_reg_16; pipeline->ps_grf_start0 = wm_prog_data->dispatch_grf_start_reg_16;
} }
anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_FRAGMENT, anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_FRAGMENT,
&prog_data->base); stage_prog_data);
return VK_SUCCESS; return VK_SUCCESS;
} }
@@ -690,7 +700,7 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler; pipeline->device->instance->physicalDevice.compiler;
struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data; const struct brw_stage_prog_data *stage_prog_data;
struct brw_cs_prog_key key; struct brw_cs_prog_key key;
uint32_t kernel; uint32_t kernel;
unsigned char sha1[20], *hash; unsigned char sha1[20], *hash;
@@ -700,23 +710,23 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
if (module->size > 0) { if (module->size > 0) {
hash = sha1; hash = sha1;
anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info); anv_hash_shader(hash, &key, sizeof(key), module, entrypoint, spec_info);
kernel = anv_pipeline_cache_search(cache, hash, prog_data); kernel = anv_pipeline_cache_search(cache, hash, &stage_prog_data);
} else { } else {
hash = NULL; hash = NULL;
} }
if (module->size == 0 || kernel == NO_KERNEL) { if (module->size == 0 || kernel == NO_KERNEL) {
memset(prog_data, 0, sizeof(*prog_data)); struct brw_cs_prog_data prog_data = { 0, };
prog_data->binding_table.work_groups_start = 0; prog_data.binding_table.work_groups_start = 0;
nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint, nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
MESA_SHADER_COMPUTE, spec_info, MESA_SHADER_COMPUTE, spec_info,
&prog_data->base); &prog_data.base);
if (nir == NULL) if (nir == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
prog_data->base.total_shared = nir->num_shared; prog_data.base.total_shared = nir->num_shared;
void *mem_ctx = ralloc_context(NULL); void *mem_ctx = ralloc_context(NULL);
@@ -725,23 +735,24 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
unsigned code_size; unsigned code_size;
const unsigned *shader_code = const unsigned *shader_code =
brw_compile_cs(compiler, NULL, mem_ctx, &key, prog_data, nir, brw_compile_cs(compiler, NULL, mem_ctx, &key, &prog_data, nir,
-1, &code_size, NULL); -1, &code_size, NULL);
if (shader_code == NULL) { if (shader_code == NULL) {
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
} }
stage_prog_data = &prog_data.base;
kernel = anv_pipeline_cache_upload_kernel(cache, hash, kernel = anv_pipeline_cache_upload_kernel(cache, hash,
shader_code, code_size, shader_code, code_size,
prog_data, sizeof(*prog_data)); &stage_prog_data, sizeof(prog_data));
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
} }
pipeline->cs_simd = kernel; pipeline->cs_simd = kernel;
anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_COMPUTE, anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_COMPUTE,
&prog_data->base); stage_prog_data);
return VK_SUCCESS; return VK_SUCCESS;
} }
@@ -751,10 +762,12 @@ gen7_compute_urb_partition(struct anv_pipeline *pipeline)
{ {
const struct brw_device_info *devinfo = &pipeline->device->info; const struct brw_device_info *devinfo = &pipeline->device->info;
bool vs_present = pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT; bool vs_present = pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT;
unsigned vs_size = vs_present ? pipeline->vs_prog_data.base.urb_entry_size : 1; unsigned vs_size = vs_present ?
get_vs_prog_data(pipeline)->base.urb_entry_size : 1;
unsigned vs_entry_size_bytes = vs_size * 64; unsigned vs_entry_size_bytes = vs_size * 64;
bool gs_present = pipeline->active_stages & VK_SHADER_STAGE_GEOMETRY_BIT; bool gs_present = pipeline->active_stages & VK_SHADER_STAGE_GEOMETRY_BIT;
unsigned gs_size = gs_present ? pipeline->gs_prog_data.base.urb_entry_size : 1; unsigned gs_size = gs_present ?
get_gs_prog_data(pipeline)->base.urb_entry_size : 1;
unsigned gs_entry_size_bytes = gs_size * 64; unsigned gs_entry_size_bytes = gs_size * 64;
/* From p35 of the Ivy Bridge PRM (section 1.7.1: 3DSTATE_URB_GS): /* From p35 of the Ivy Bridge PRM (section 1.7.1: 3DSTATE_URB_GS):
@@ -1136,7 +1149,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
if (!(pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT)) { if (!(pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT)) {
/* Vertex is only optional if disable_vs is set */ /* Vertex is only optional if disable_vs is set */
assert(extra->disable_vs); assert(extra->disable_vs);
memset(&pipeline->vs_prog_data, 0, sizeof(pipeline->vs_prog_data));
} }
gen7_compute_urb_partition(pipeline); gen7_compute_urb_partition(pipeline);
@@ -1152,7 +1164,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
*/ */
inputs_read = ~0ull; inputs_read = ~0ull;
} else { } else {
inputs_read = pipeline->vs_prog_data.inputs_read; inputs_read = get_vs_prog_data(pipeline)->inputs_read;
} }
pipeline->vb_used = 0; pipeline->vb_used = 0;

View File

@@ -110,7 +110,8 @@ anv_hash_shader(unsigned char *hash, const void *key, size_t key_size,
uint32_t uint32_t
anv_pipeline_cache_search(struct anv_pipeline_cache *cache, anv_pipeline_cache_search(struct anv_pipeline_cache *cache,
const unsigned char *sha1, void *prog_data) const unsigned char *sha1,
const struct brw_stage_prog_data **prog_data)
{ {
const uint32_t mask = cache->table_size - 1; const uint32_t mask = cache->table_size - 1;
const uint32_t start = (*(uint32_t *) sha1); const uint32_t start = (*(uint32_t *) sha1);
@@ -126,7 +127,7 @@ anv_pipeline_cache_search(struct anv_pipeline_cache *cache,
cache->program_stream.block_pool->map + offset; cache->program_stream.block_pool->map + offset;
if (memcmp(entry->sha1, sha1, sizeof(entry->sha1)) == 0) { if (memcmp(entry->sha1, sha1, sizeof(entry->sha1)) == 0) {
if (prog_data) if (prog_data)
memcpy(prog_data, entry->prog_data, entry->prog_data_size); *prog_data = (const struct brw_stage_prog_data *) entry->prog_data;
const uint32_t preamble_size = const uint32_t preamble_size =
align_u32(sizeof(*entry) + entry->prog_data_size, 64); align_u32(sizeof(*entry) + entry->prog_data_size, 64);
@@ -198,17 +199,14 @@ uint32_t
anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache, anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
const unsigned char *sha1, const unsigned char *sha1,
const void *kernel, size_t kernel_size, const void *kernel, size_t kernel_size,
const void *prog_data, size_t prog_data_size) const struct brw_stage_prog_data **prog_data,
size_t prog_data_size)
{ {
pthread_mutex_lock(&cache->mutex); pthread_mutex_lock(&cache->mutex);
struct cache_entry *entry; struct cache_entry *entry;
/* Meta pipelines don't have SPIR-V, so we can't hash them. const uint32_t preamble_size =
* Consequentally, they just don't get cached. align_u32(sizeof(*entry) + prog_data_size, 64);
*/
const uint32_t preamble_size = sha1 ?
align_u32(sizeof(*entry) + prog_data_size, 64) :
0;
const uint32_t size = preamble_size + kernel_size; const uint32_t size = preamble_size + kernel_size;
@@ -216,14 +214,16 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
const struct anv_state state = const struct anv_state state =
anv_state_stream_alloc(&cache->program_stream, size, 64); anv_state_stream_alloc(&cache->program_stream, size, 64);
entry = state.map;
entry->prog_data_size = prog_data_size;
memcpy(entry->prog_data, *prog_data, prog_data_size);
*prog_data = (const struct brw_stage_prog_data *) entry->prog_data;
entry->kernel_size = kernel_size;
if (sha1 && env_var_as_boolean("ANV_ENABLE_PIPELINE_CACHE", false)) { if (sha1 && env_var_as_boolean("ANV_ENABLE_PIPELINE_CACHE", false)) {
assert(anv_pipeline_cache_search(cache, sha1, NULL) == NO_KERNEL); assert(anv_pipeline_cache_search(cache, sha1, NULL) == NO_KERNEL);
entry = state.map;
memcpy(entry->sha1, sha1, sizeof(entry->sha1));
entry->prog_data_size = prog_data_size;
memcpy(entry->prog_data, prog_data, prog_data_size);
entry->kernel_size = kernel_size;
memcpy(entry->sha1, sha1, sizeof(entry->sha1));
if (cache->kernel_count == cache->table_size / 2) if (cache->kernel_count == cache->table_size / 2)
anv_pipeline_cache_grow(cache); anv_pipeline_cache_grow(cache);
@@ -285,9 +285,13 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
const struct cache_entry *entry = p; const struct cache_entry *entry = p;
const void *kernel = &entry->prog_data[entry->prog_data_size]; const void *kernel = &entry->prog_data[entry->prog_data_size];
const struct brw_stage_prog_data *prog_data =
(const struct brw_stage_prog_data *) entry->prog_data;
anv_pipeline_cache_upload_kernel(cache, entry->sha1, anv_pipeline_cache_upload_kernel(cache, entry->sha1,
kernel, entry->kernel_size, kernel, entry->kernel_size,
entry->prog_data, entry->prog_data_size); &prog_data,
entry->prog_data_size);
p = kernel + entry->kernel_size; p = kernel + entry->kernel_size;
} }
} }
@@ -406,9 +410,12 @@ anv_pipeline_cache_merge(struct anv_pipeline_cache *dst,
const void *kernel = (void *) entry + const void *kernel = (void *) entry +
align_u32(sizeof(*entry) + entry->prog_data_size, 64); align_u32(sizeof(*entry) + entry->prog_data_size, 64);
const struct brw_stage_prog_data *prog_data =
(const struct brw_stage_prog_data *) entry->prog_data;
anv_pipeline_cache_upload_kernel(dst, entry->sha1, anv_pipeline_cache_upload_kernel(dst, entry->sha1,
kernel, entry->kernel_size, kernel, entry->kernel_size,
entry->prog_data, entry->prog_data_size); &prog_data, entry->prog_data_size);
} }
} }

View File

@@ -640,12 +640,13 @@ void anv_pipeline_cache_init(struct anv_pipeline_cache *cache,
struct anv_device *device); struct anv_device *device);
void anv_pipeline_cache_finish(struct anv_pipeline_cache *cache); void anv_pipeline_cache_finish(struct anv_pipeline_cache *cache);
uint32_t anv_pipeline_cache_search(struct anv_pipeline_cache *cache, uint32_t anv_pipeline_cache_search(struct anv_pipeline_cache *cache,
const unsigned char *sha1, void *prog_data); const unsigned char *sha1,
const struct brw_stage_prog_data **prog_data);
uint32_t anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache, uint32_t anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
const unsigned char *sha1, const unsigned char *sha1,
const void *kernel, const void *kernel,
size_t kernel_size, size_t kernel_size,
const void *prog_data, const struct brw_stage_prog_data **prog_data,
size_t prog_data_size); size_t prog_data_size);
struct anv_device { struct anv_device {
@@ -1404,12 +1405,8 @@ struct anv_pipeline {
bool use_repclear; bool use_repclear;
struct brw_vs_prog_data vs_prog_data;
struct brw_wm_prog_data wm_prog_data;
struct brw_gs_prog_data gs_prog_data;
struct brw_cs_prog_data cs_prog_data;
bool writes_point_size; bool writes_point_size;
struct brw_stage_prog_data * prog_data[MESA_SHADER_STAGES]; const struct brw_stage_prog_data * prog_data[MESA_SHADER_STAGES];
uint32_t scratch_start[MESA_SHADER_STAGES]; uint32_t scratch_start[MESA_SHADER_STAGES];
uint32_t total_scratch; uint32_t total_scratch;
struct { struct {
@@ -1457,6 +1454,30 @@ struct anv_pipeline {
} gen9; } gen9;
}; };
static inline const struct brw_vs_prog_data *
get_vs_prog_data(struct anv_pipeline *pipeline)
{
return (const struct brw_vs_prog_data *) pipeline->prog_data[MESA_SHADER_VERTEX];
}
static inline const struct brw_gs_prog_data *
get_gs_prog_data(struct anv_pipeline *pipeline)
{
return (const struct brw_gs_prog_data *) pipeline->prog_data[MESA_SHADER_GEOMETRY];
}
static inline const struct brw_wm_prog_data *
get_wm_prog_data(struct anv_pipeline *pipeline)
{
return (const struct brw_wm_prog_data *) pipeline->prog_data[MESA_SHADER_FRAGMENT];
}
static inline const struct brw_cs_prog_data *
get_cs_prog_data(struct anv_pipeline *pipeline)
{
return (const struct brw_cs_prog_data *) pipeline->prog_data[MESA_SHADER_COMPUTE];
}
struct anv_graphics_pipeline_create_info { struct anv_graphics_pipeline_create_info {
/** /**
* If non-negative, overrides the color attachment count of the pipeline's * If non-negative, overrides the color attachment count of the pipeline's

View File

@@ -283,7 +283,7 @@ flush_compute_descriptor_set(struct anv_cmd_buffer *cmd_buffer)
struct anv_state push_state = anv_cmd_buffer_cs_push_constants(cmd_buffer); struct anv_state push_state = anv_cmd_buffer_cs_push_constants(cmd_buffer);
const struct brw_cs_prog_data *cs_prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
const struct brw_stage_prog_data *prog_data = &cs_prog_data->base; const struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8; unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8;
@@ -395,11 +395,12 @@ void
genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer) genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer)
{ {
struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
VkResult result; VkResult result;
assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT); assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT);
bool needs_slm = pipeline->cs_prog_data.base.total_shared > 0; bool needs_slm = cs_prog_data->base.total_shared > 0;
config_l3(cmd_buffer, needs_slm); config_l3(cmd_buffer, needs_slm);
if (cmd_buffer->state.current_pipeline != GPGPU) { if (cmd_buffer->state.current_pipeline != GPGPU) {

View File

@@ -250,7 +250,7 @@ genX(graphics_pipeline_create)(
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_SAMPLE_MASK), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_SAMPLE_MASK),
.SampleMask = 0xff); .SampleMask = 0xff);
const struct brw_vue_prog_data *vue_prog_data = &pipeline->vs_prog_data.base; const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
#if 0 #if 0
/* From gen7_vs_state.c */ /* From gen7_vs_state.c */
@@ -277,18 +277,18 @@ genX(graphics_pipeline_create)(
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VS), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VS),
.KernelStartPointer = pipeline->vs_vec4, .KernelStartPointer = pipeline->vs_vec4,
.ScratchSpaceBaseOffset = pipeline->scratch_start[MESA_SHADER_VERTEX], .ScratchSpaceBaseOffset = pipeline->scratch_start[MESA_SHADER_VERTEX],
.PerThreadScratchSpace = scratch_space(&vue_prog_data->base), .PerThreadScratchSpace = scratch_space(&vs_prog_data->base.base),
.DispatchGRFStartRegisterforURBData = .DispatchGRFStartRegisterforURBData =
vue_prog_data->base.dispatch_grf_start_reg, vs_prog_data->base.base.dispatch_grf_start_reg,
.VertexURBEntryReadLength = vue_prog_data->urb_read_length, .VertexURBEntryReadLength = vs_prog_data->base.urb_read_length,
.VertexURBEntryReadOffset = 0, .VertexURBEntryReadOffset = 0,
.MaximumNumberofThreads = device->info.max_vs_threads - 1, .MaximumNumberofThreads = device->info.max_vs_threads - 1,
.StatisticsEnable = true, .StatisticsEnable = true,
.VSFunctionEnable = true); .VSFunctionEnable = true);
const struct brw_gs_prog_data *gs_prog_data = &pipeline->gs_prog_data; const struct brw_gs_prog_data *gs_prog_data = get_gs_prog_data(pipeline);
if (pipeline->gs_kernel == NO_KERNEL || (extra && extra->disable_vs)) { if (pipeline->gs_kernel == NO_KERNEL || (extra && extra->disable_vs)) {
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .GSEnable = false); anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .GSEnable = false);
@@ -338,7 +338,7 @@ genX(graphics_pipeline_create)(
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS),
.MaximumNumberofThreads = device->info.max_wm_threads - 1); .MaximumNumberofThreads = device->info.max_wm_threads - 1);
} else { } else {
const struct brw_wm_prog_data *wm_prog_data = &pipeline->wm_prog_data; const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
if (wm_prog_data->urb_setup[VARYING_SLOT_BFC0] != -1 || if (wm_prog_data->urb_setup[VARYING_SLOT_BFC0] != -1 ||
wm_prog_data->urb_setup[VARYING_SLOT_BFC1] != -1) wm_prog_data->urb_setup[VARYING_SLOT_BFC1] != -1)
anv_finishme("two-sided color needs sbe swizzling setup"); anv_finishme("two-sided color needs sbe swizzling setup");

View File

@@ -505,7 +505,7 @@ flush_compute_descriptor_set(struct anv_cmd_buffer *cmd_buffer)
struct anv_state push_state = anv_cmd_buffer_cs_push_constants(cmd_buffer); struct anv_state push_state = anv_cmd_buffer_cs_push_constants(cmd_buffer);
const struct brw_cs_prog_data *cs_prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
const struct brw_stage_prog_data *prog_data = &cs_prog_data->base; const struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8; unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8;
@@ -558,11 +558,12 @@ void
genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer) genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer)
{ {
struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
VkResult result; VkResult result;
assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT); assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT);
bool needs_slm = pipeline->cs_prog_data.base.total_shared > 0; bool needs_slm = cs_prog_data->base.total_shared > 0;
config_l3(cmd_buffer, needs_slm); config_l3(cmd_buffer, needs_slm);
if (cmd_buffer->state.current_pipeline != GPGPU) { if (cmd_buffer->state.current_pipeline != GPGPU) {

View File

@@ -354,6 +354,7 @@ genX(graphics_pipeline_create)(
.MaximumPointWidth = 255.875, .MaximumPointWidth = 255.875,
.MaximumVPIndex = pCreateInfo->pViewportState->viewportCount - 1); .MaximumVPIndex = pCreateInfo->pViewportState->viewportCount - 1);
const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_WM), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_WM),
.StatisticsEnable = true, .StatisticsEnable = true,
.LineEndCapAntialiasingRegionWidth = _05pixels, .LineEndCapAntialiasingRegionWidth = _05pixels,
@@ -363,15 +364,15 @@ genX(graphics_pipeline_create)(
.PointRasterizationRule = RASTRULE_UPPER_RIGHT, .PointRasterizationRule = RASTRULE_UPPER_RIGHT,
.BarycentricInterpolationMode = .BarycentricInterpolationMode =
pipeline->ps_ksp0 == NO_KERNEL ? pipeline->ps_ksp0 == NO_KERNEL ?
0 : pipeline->wm_prog_data.barycentric_interp_modes); 0 : wm_prog_data->barycentric_interp_modes);
const struct brw_gs_prog_data *gs_prog_data = &pipeline->gs_prog_data; if (pipeline->gs_kernel == NO_KERNEL) {
offset = 1;
length = (gs_prog_data->base.vue_map.num_slots + 1) / 2 - offset;
if (pipeline->gs_kernel == NO_KERNEL)
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .Enable = false); anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .Enable = false);
else } else {
const struct brw_gs_prog_data *gs_prog_data = get_gs_prog_data(pipeline);
offset = 1;
length = (gs_prog_data->base.vue_map.num_slots + 1) / 2 - offset;
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS),
.SingleProgramFlow = false, .SingleProgramFlow = false,
.KernelStartPointer = pipeline->gs_kernel, .KernelStartPointer = pipeline->gs_kernel,
@@ -412,11 +413,12 @@ genX(graphics_pipeline_create)(
.VertexURBEntryOutputReadOffset = offset, .VertexURBEntryOutputReadOffset = offset,
.VertexURBEntryOutputLength = length); .VertexURBEntryOutputLength = length);
}
const struct brw_vue_prog_data *vue_prog_data = &pipeline->vs_prog_data.base; const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
/* Skip the VUE header and position slots */ /* Skip the VUE header and position slots */
offset = 1; offset = 1;
length = (vue_prog_data->vue_map.num_slots + 1) / 2 - offset; length = (vs_prog_data->base.vue_map.num_slots + 1) / 2 - offset;
uint32_t vs_start = pipeline->vs_simd8 != NO_KERNEL ? pipeline->vs_simd8 : uint32_t vs_start = pipeline->vs_simd8 != NO_KERNEL ? pipeline->vs_simd8 :
pipeline->vs_vec4; pipeline->vs_vec4;
@@ -435,7 +437,7 @@ genX(graphics_pipeline_create)(
.VectorMaskEnable = false, .VectorMaskEnable = false,
.SamplerCount = 0, .SamplerCount = 0,
.BindingTableEntryCount = .BindingTableEntryCount =
vue_prog_data->base.binding_table.size_bytes / 4, vs_prog_data->base.base.binding_table.size_bytes / 4,
.ThreadDispatchPriority = false, .ThreadDispatchPriority = false,
.FloatingPointMode = IEEE754, .FloatingPointMode = IEEE754,
.IllegalOpcodeExceptionEnable = false, .IllegalOpcodeExceptionEnable = false,
@@ -443,11 +445,11 @@ genX(graphics_pipeline_create)(
.SoftwareExceptionEnable = false, .SoftwareExceptionEnable = false,
.ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_VERTEX], .ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_VERTEX],
.PerThreadScratchSpace = scratch_space(&vue_prog_data->base), .PerThreadScratchSpace = scratch_space(&vs_prog_data->base.base),
.DispatchGRFStartRegisterForURBData = .DispatchGRFStartRegisterForURBData =
vue_prog_data->base.dispatch_grf_start_reg, vs_prog_data->base.base.dispatch_grf_start_reg,
.VertexURBEntryReadLength = vue_prog_data->urb_read_length, .VertexURBEntryReadLength = vs_prog_data->base.urb_read_length,
.VertexURBEntryReadOffset = 0, .VertexURBEntryReadOffset = 0,
.MaximumNumberofThreads = device->info.max_vs_threads - 1, .MaximumNumberofThreads = device->info.max_vs_threads - 1,
@@ -461,8 +463,6 @@ genX(graphics_pipeline_create)(
.UserClipDistanceClipTestEnableBitmask = 0, .UserClipDistanceClipTestEnableBitmask = 0,
.UserClipDistanceCullTestEnableBitmask = 0); .UserClipDistanceCullTestEnableBitmask = 0);
const struct brw_wm_prog_data *wm_prog_data = &pipeline->wm_prog_data;
const int num_thread_bias = GEN_GEN == 8 ? 2 : 1; const int num_thread_bias = GEN_GEN == 8 ? 2 : 1;
if (pipeline->ps_ksp0 == NO_KERNEL) { if (pipeline->ps_ksp0 == NO_KERNEL) {
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS)); anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS));

View File

@@ -319,11 +319,11 @@ void genX(CmdDraw)(
{ {
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
genX(cmd_buffer_flush_state)(cmd_buffer); genX(cmd_buffer_flush_state)(cmd_buffer);
if (cmd_buffer->state.pipeline->vs_prog_data.uses_basevertex || if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
cmd_buffer->state.pipeline->vs_prog_data.uses_baseinstance)
emit_base_vertex_instance(cmd_buffer, firstVertex, firstInstance); emit_base_vertex_instance(cmd_buffer, firstVertex, firstInstance);
anv_batch_emit(&cmd_buffer->batch, GENX(3DPRIMITIVE), anv_batch_emit(&cmd_buffer->batch, GENX(3DPRIMITIVE),
@@ -346,11 +346,11 @@ void genX(CmdDrawIndexed)(
{ {
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
genX(cmd_buffer_flush_state)(cmd_buffer); genX(cmd_buffer_flush_state)(cmd_buffer);
if (cmd_buffer->state.pipeline->vs_prog_data.uses_basevertex || if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
cmd_buffer->state.pipeline->vs_prog_data.uses_baseinstance)
emit_base_vertex_instance(cmd_buffer, vertexOffset, firstInstance); emit_base_vertex_instance(cmd_buffer, vertexOffset, firstInstance);
anv_batch_emit(&cmd_buffer->batch, GENX(3DPRIMITIVE), anv_batch_emit(&cmd_buffer->batch, GENX(3DPRIMITIVE),
@@ -398,13 +398,13 @@ void genX(CmdDrawIndirect)(
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer); ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
struct anv_bo *bo = buffer->bo; struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset; uint32_t bo_offset = buffer->offset + offset;
genX(cmd_buffer_flush_state)(cmd_buffer); genX(cmd_buffer_flush_state)(cmd_buffer);
if (cmd_buffer->state.pipeline->vs_prog_data.uses_basevertex || if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
cmd_buffer->state.pipeline->vs_prog_data.uses_baseinstance)
emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 8); emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 8);
emit_lrm(&cmd_buffer->batch, GEN7_3DPRIM_VERTEX_COUNT, bo, bo_offset); emit_lrm(&cmd_buffer->batch, GEN7_3DPRIM_VERTEX_COUNT, bo, bo_offset);
@@ -429,14 +429,14 @@ void genX(CmdDrawIndexedIndirect)(
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer); ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
struct anv_bo *bo = buffer->bo; struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset; uint32_t bo_offset = buffer->offset + offset;
genX(cmd_buffer_flush_state)(cmd_buffer); genX(cmd_buffer_flush_state)(cmd_buffer);
/* TODO: We need to stomp base vertex to 0 somehow */ /* TODO: We need to stomp base vertex to 0 somehow */
if (cmd_buffer->state.pipeline->vs_prog_data.uses_basevertex || if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
cmd_buffer->state.pipeline->vs_prog_data.uses_baseinstance)
emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 12); emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 12);
emit_lrm(&cmd_buffer->batch, GEN7_3DPRIM_VERTEX_COUNT, bo, bo_offset); emit_lrm(&cmd_buffer->batch, GEN7_3DPRIM_VERTEX_COUNT, bo, bo_offset);
@@ -460,7 +460,7 @@ void genX(CmdDispatch)(
{ {
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *prog_data = get_cs_prog_data(pipeline);
if (prog_data->uses_num_work_groups) { if (prog_data->uses_num_work_groups) {
struct anv_state state = struct anv_state state =
@@ -507,7 +507,7 @@ void genX(CmdDispatchIndirect)(
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer); ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline; struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *prog_data = get_cs_prog_data(pipeline);
struct anv_bo *bo = buffer->bo; struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset; uint32_t bo_offset = buffer->offset + offset;
struct anv_batch *batch = &cmd_buffer->batch; struct anv_batch *batch = &cmd_buffer->batch;

View File

@@ -82,7 +82,7 @@ genX(compute_pipeline_create)(
pipeline->use_repclear = false; pipeline->use_repclear = false;
const struct brw_cs_prog_data *cs_prog_data = &pipeline->cs_prog_data; const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
const struct brw_stage_prog_data *prog_data = &cs_prog_data->base; const struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8; unsigned local_id_dwords = cs_prog_data->local_invocation_id_regs * 8;

View File

@@ -52,6 +52,8 @@ emit_vertex_input(struct anv_pipeline *pipeline,
const VkPipelineVertexInputStateCreateInfo *info, const VkPipelineVertexInputStateCreateInfo *info,
const struct anv_graphics_pipeline_create_info *extra) const struct anv_graphics_pipeline_create_info *extra)
{ {
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
uint32_t elements; uint32_t elements;
if (extra && extra->disable_vs) { if (extra && extra->disable_vs) {
/* If the VS is disabled, just assume the user knows what they're /* If the VS is disabled, just assume the user knows what they're
@@ -63,7 +65,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
elements |= (1 << info->pVertexAttributeDescriptions[i].location); elements |= (1 << info->pVertexAttributeDescriptions[i].location);
} else { } else {
/* Pull inputs_read out of the VS prog data */ /* Pull inputs_read out of the VS prog data */
uint64_t inputs_read = pipeline->vs_prog_data.inputs_read; uint64_t inputs_read = vs_prog_data->inputs_read;
assert((inputs_read & ((1 << VERT_ATTRIB_GENERIC0) - 1)) == 0); assert((inputs_read & ((1 << VERT_ATTRIB_GENERIC0) - 1)) == 0);
elements = inputs_read >> VERT_ATTRIB_GENERIC0; elements = inputs_read >> VERT_ATTRIB_GENERIC0;
} }
@@ -72,16 +74,16 @@ emit_vertex_input(struct anv_pipeline *pipeline,
/* On BDW+, we only need to allocate space for base ids. Setting up /* On BDW+, we only need to allocate space for base ids. Setting up
* the actual vertex and instance id is a separate packet. * the actual vertex and instance id is a separate packet.
*/ */
const bool needs_svgs_elem = pipeline->vs_prog_data.uses_basevertex || const bool needs_svgs_elem = vs_prog_data->uses_basevertex ||
pipeline->vs_prog_data.uses_baseinstance; vs_prog_data->uses_baseinstance;
#else #else
/* On Haswell and prior, vertex and instance id are created by using the /* On Haswell and prior, vertex and instance id are created by using the
* ComponentControl fields, so we need an element for any of them. * ComponentControl fields, so we need an element for any of them.
*/ */
const bool needs_svgs_elem = pipeline->vs_prog_data.uses_vertexid || const bool needs_svgs_elem = vs_prog_data->uses_vertexid ||
pipeline->vs_prog_data.uses_instanceid || vs_prog_data->uses_instanceid ||
pipeline->vs_prog_data.uses_basevertex || vs_prog_data->uses_basevertex ||
pipeline->vs_prog_data.uses_baseinstance; vs_prog_data->uses_baseinstance;
#endif #endif
uint32_t elem_count = __builtin_popcount(elements) + needs_svgs_elem; uint32_t elem_count = __builtin_popcount(elements) + needs_svgs_elem;
@@ -148,8 +150,8 @@ emit_vertex_input(struct anv_pipeline *pipeline,
* This means, that if we have BaseInstance, we need BaseVertex as * This means, that if we have BaseInstance, we need BaseVertex as
* well. Just do all or nothing. * well. Just do all or nothing.
*/ */
uint32_t base_ctrl = (pipeline->vs_prog_data.uses_basevertex || uint32_t base_ctrl = (vs_prog_data->uses_basevertex ||
pipeline->vs_prog_data.uses_baseinstance) ? vs_prog_data->uses_baseinstance) ?
VFCOMP_STORE_SRC : VFCOMP_STORE_0; VFCOMP_STORE_SRC : VFCOMP_STORE_0;
struct GENX(VERTEX_ELEMENT_STATE) element = { struct GENX(VERTEX_ELEMENT_STATE) element = {
@@ -171,10 +173,10 @@ emit_vertex_input(struct anv_pipeline *pipeline,
#if GEN_GEN >= 8 #if GEN_GEN >= 8
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_SGVS), anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_SGVS),
.VertexIDEnable = pipeline->vs_prog_data.uses_vertexid, .VertexIDEnable = vs_prog_data->uses_vertexid,
.VertexIDComponentNumber = 2, .VertexIDComponentNumber = 2,
.VertexIDElementOffset = id_slot, .VertexIDElementOffset = id_slot,
.InstanceIDEnable = pipeline->vs_prog_data.uses_instanceid, .InstanceIDEnable = vs_prog_data->uses_instanceid,
.InstanceIDComponentNumber = 3, .InstanceIDComponentNumber = 3,
.InstanceIDElementOffset = id_slot); .InstanceIDElementOffset = id_slot);
#endif #endif
@@ -222,17 +224,21 @@ emit_urb_setup(struct anv_pipeline *pipeline)
static void static void
emit_3dstate_sbe(struct anv_pipeline *pipeline) emit_3dstate_sbe(struct anv_pipeline *pipeline)
{ {
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
const struct brw_gs_prog_data *gs_prog_data = get_gs_prog_data(pipeline);
const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
const struct brw_vue_map *fs_input_map; const struct brw_vue_map *fs_input_map;
if (pipeline->gs_kernel == NO_KERNEL) if (pipeline->gs_kernel == NO_KERNEL)
fs_input_map = &pipeline->vs_prog_data.base.vue_map; fs_input_map = &vs_prog_data->base.vue_map;
else else
fs_input_map = &pipeline->gs_prog_data.base.vue_map; fs_input_map = &gs_prog_data->base.vue_map;
struct GENX(3DSTATE_SBE) sbe = { struct GENX(3DSTATE_SBE) sbe = {
GENX(3DSTATE_SBE_header), GENX(3DSTATE_SBE_header),
.AttributeSwizzleEnable = true, .AttributeSwizzleEnable = true,
.PointSpriteTextureCoordinateOrigin = UPPERLEFT, .PointSpriteTextureCoordinateOrigin = UPPERLEFT,
.NumberofSFOutputAttributes = pipeline->wm_prog_data.num_varying_inputs, .NumberofSFOutputAttributes = wm_prog_data->num_varying_inputs,
#if GEN_GEN >= 9 #if GEN_GEN >= 9
.Attribute0ActiveComponentFormat = ACF_XYZW, .Attribute0ActiveComponentFormat = ACF_XYZW,
@@ -283,7 +289,7 @@ emit_3dstate_sbe(struct anv_pipeline *pipeline)
int max_source_attr = 0; int max_source_attr = 0;
for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) { for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
int input_index = pipeline->wm_prog_data.urb_setup[attr]; int input_index = wm_prog_data->urb_setup[attr];
if (input_index < 0) if (input_index < 0)
continue; continue;