tu: Remove tu_shader_compile_options
The only two fields were always true, and I don't think we'd ever have use for them. If we want to disable optimizations then we'd need a different approach, and I don't even know what include_binning_pass was for. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5500>
This commit is contained in:
@@ -1950,6 +1950,39 @@ tu_pipeline_create(struct tu_device *dev,
|
|||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tu_pipeline_shader_key_init(struct ir3_shader_key *key,
|
||||||
|
const VkGraphicsPipelineCreateInfo *pipeline_info)
|
||||||
|
{
|
||||||
|
bool has_gs = false;
|
||||||
|
bool msaa = false;
|
||||||
|
if (pipeline_info) {
|
||||||
|
for (uint32_t i = 0; i < pipeline_info->stageCount; i++) {
|
||||||
|
if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) {
|
||||||
|
has_gs = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState;
|
||||||
|
const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations =
|
||||||
|
vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT);
|
||||||
|
if (!pipeline_info->pRasterizationState->rasterizerDiscardEnable &&
|
||||||
|
(msaa_info->rasterizationSamples > 1 ||
|
||||||
|
/* also set msaa key when sample location is not the default
|
||||||
|
* since this affects varying interpolation */
|
||||||
|
(sample_locations && sample_locations->sampleLocationsEnable))) {
|
||||||
|
msaa = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: Populate the remaining fields of ir3_shader_key. */
|
||||||
|
*key = (struct ir3_shader_key) {
|
||||||
|
.has_gs = has_gs,
|
||||||
|
.msaa = msaa,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static VkResult
|
static VkResult
|
||||||
tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
|
tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
|
||||||
{
|
{
|
||||||
@@ -1962,8 +1995,8 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
|
|||||||
stage_infos[stage] = &builder->create_info->pStages[i];
|
stage_infos[stage] = &builder->create_info->pStages[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tu_shader_compile_options options;
|
struct ir3_shader_key key;
|
||||||
tu_shader_compile_options_init(&options, builder->create_info);
|
tu_pipeline_shader_key_init(&key, builder->create_info);
|
||||||
|
|
||||||
for (gl_shader_stage stage = MESA_SHADER_VERTEX;
|
for (gl_shader_stage stage = MESA_SHADER_VERTEX;
|
||||||
stage < MESA_SHADER_STAGES; stage++) {
|
stage < MESA_SHADER_STAGES; stage++) {
|
||||||
@@ -1988,7 +2021,7 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
|
|||||||
bool created;
|
bool created;
|
||||||
builder->variants[stage] =
|
builder->variants[stage] =
|
||||||
ir3_shader_get_variant(builder->shaders[stage]->ir3_shader,
|
ir3_shader_get_variant(builder->shaders[stage]->ir3_shader,
|
||||||
&options.key, false, &created);
|
&key, false, &created);
|
||||||
if (!builder->variants[stage])
|
if (!builder->variants[stage])
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
|
|
||||||
@@ -1997,26 +2030,24 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
|
|||||||
sizeof(uint32_t) * builder->variants[stage]->info.sizedwords;
|
sizeof(uint32_t) * builder->variants[stage]->info.sizedwords;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.include_binning_pass) {
|
const struct tu_shader *vs = builder->shaders[MESA_SHADER_VERTEX];
|
||||||
const struct tu_shader *vs = builder->shaders[MESA_SHADER_VERTEX];
|
struct ir3_shader_variant *variant;
|
||||||
struct ir3_shader_variant *variant;
|
|
||||||
|
|
||||||
if (vs->ir3_shader->stream_output.num_outputs) {
|
if (vs->ir3_shader->stream_output.num_outputs) {
|
||||||
variant = builder->variants[MESA_SHADER_VERTEX];
|
variant = builder->variants[MESA_SHADER_VERTEX];
|
||||||
} else {
|
} else {
|
||||||
bool created;
|
bool created;
|
||||||
variant = ir3_shader_get_variant(vs->ir3_shader, &options.key,
|
variant = ir3_shader_get_variant(vs->ir3_shader, &key,
|
||||||
true, &created);
|
true, &created);
|
||||||
if (!variant)
|
if (!variant)
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
|
||||||
|
|
||||||
builder->binning_vs_offset = builder->shader_total_size;
|
|
||||||
builder->shader_total_size +=
|
|
||||||
sizeof(uint32_t) * variant->info.sizedwords;
|
|
||||||
builder->binning_variant = variant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder->binning_vs_offset = builder->shader_total_size;
|
||||||
|
builder->shader_total_size +=
|
||||||
|
sizeof(uint32_t) * variant->info.sizedwords;
|
||||||
|
builder->binning_variant = variant;
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2554,8 +2585,8 @@ tu_compute_pipeline_create(VkDevice device,
|
|||||||
|
|
||||||
pipeline->layout = layout;
|
pipeline->layout = layout;
|
||||||
|
|
||||||
struct tu_shader_compile_options options;
|
struct ir3_shader_key key;
|
||||||
tu_shader_compile_options_init(&options, NULL);
|
tu_pipeline_shader_key_init(&key, NULL);
|
||||||
|
|
||||||
struct tu_shader *shader =
|
struct tu_shader *shader =
|
||||||
tu_shader_create(dev, MESA_SHADER_COMPUTE, stage_info, layout, pAllocator);
|
tu_shader_create(dev, MESA_SHADER_COMPUTE, stage_info, layout, pAllocator);
|
||||||
@@ -2566,7 +2597,7 @@ tu_compute_pipeline_create(VkDevice device,
|
|||||||
|
|
||||||
bool created;
|
bool created;
|
||||||
struct ir3_shader_variant *v =
|
struct ir3_shader_variant *v =
|
||||||
ir3_shader_get_variant(shader->ir3_shader, &options.key, false, &created);
|
ir3_shader_get_variant(shader->ir3_shader, &key, false, &created);
|
||||||
if (!v)
|
if (!v)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@@ -1098,14 +1098,6 @@ struct tu_shader_module
|
|||||||
const uint32_t *code[0];
|
const uint32_t *code[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tu_shader_compile_options
|
|
||||||
{
|
|
||||||
struct ir3_shader_key key;
|
|
||||||
|
|
||||||
bool optimize;
|
|
||||||
bool include_binning_pass;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tu_push_constant_range
|
struct tu_push_constant_range
|
||||||
{
|
{
|
||||||
uint32_t lo;
|
uint32_t lo;
|
||||||
@@ -1133,11 +1125,6 @@ tu_shader_destroy(struct tu_device *dev,
|
|||||||
struct tu_shader *shader,
|
struct tu_shader *shader,
|
||||||
const VkAllocationCallbacks *alloc);
|
const VkAllocationCallbacks *alloc);
|
||||||
|
|
||||||
void
|
|
||||||
tu_shader_compile_options_init(
|
|
||||||
struct tu_shader_compile_options *options,
|
|
||||||
const VkGraphicsPipelineCreateInfo *pipeline_info);
|
|
||||||
|
|
||||||
struct tu_program_descriptor_linkage
|
struct tu_program_descriptor_linkage
|
||||||
{
|
{
|
||||||
struct ir3_ubo_analysis_state ubo_state;
|
struct ir3_ubo_analysis_state ubo_state;
|
||||||
|
@@ -657,47 +657,6 @@ tu_shader_destroy(struct tu_device *dev,
|
|||||||
vk_free2(&dev->alloc, alloc, shader);
|
vk_free2(&dev->alloc, alloc, shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tu_shader_compile_options_init(
|
|
||||||
struct tu_shader_compile_options *options,
|
|
||||||
const VkGraphicsPipelineCreateInfo *pipeline_info)
|
|
||||||
{
|
|
||||||
bool has_gs = false;
|
|
||||||
bool msaa = false;
|
|
||||||
if (pipeline_info) {
|
|
||||||
for (uint32_t i = 0; i < pipeline_info->stageCount; i++) {
|
|
||||||
if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) {
|
|
||||||
has_gs = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState;
|
|
||||||
const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations =
|
|
||||||
vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT);
|
|
||||||
if (!pipeline_info->pRasterizationState->rasterizerDiscardEnable &&
|
|
||||||
(msaa_info->rasterizationSamples > 1 ||
|
|
||||||
/* also set msaa key when sample location is not the default
|
|
||||||
* since this affects varying interpolation */
|
|
||||||
(sample_locations && sample_locations->sampleLocationsEnable))) {
|
|
||||||
msaa = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*options = (struct tu_shader_compile_options) {
|
|
||||||
/* TODO: Populate the remaining fields of ir3_shader_key. */
|
|
||||||
.key = {
|
|
||||||
.has_gs = has_gs,
|
|
||||||
.msaa = msaa,
|
|
||||||
},
|
|
||||||
/* TODO: VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT
|
|
||||||
* some optimizations need to happen otherwise shader might not compile
|
|
||||||
*/
|
|
||||||
.optimize = true,
|
|
||||||
.include_binning_pass = true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
tu_CreateShaderModule(VkDevice _device,
|
tu_CreateShaderModule(VkDevice _device,
|
||||||
const VkShaderModuleCreateInfo *pCreateInfo,
|
const VkShaderModuleCreateInfo *pCreateInfo,
|
||||||
|
Reference in New Issue
Block a user