unsigned slot = reverse_map[output->register_index];
/* always set stride to be used during draw */
zs->sinfo.so_info.stride[output->output_buffer] = so_info->stride[output->output_buffer];
- if (zs->nir->info.stage != MESA_SHADER_GEOMETRY || util_bitcount(zs->nir->info.gs.active_stream_mask) == 1) {
+ if (zs->info.stage != MESA_SHADER_GEOMETRY || util_bitcount(zs->info.gs.active_stream_mask) == 1) {
nir_variable *var = NULL;
unsigned so_slot;
while (!var)
VkSpecializationInfo sinfo = {0};
VkSpecializationMapEntry me[3];
uint32_t size[3] = {1,1,1};
- if (!zs->nir->info.workgroup_size[0]) {
+ if (!zs->info.workgroup_size[0]) {
sinfo.mapEntryCount = 3;
sinfo.pMapEntries = &me[0];
sinfo.dataSize = sizeof(uint32_t) * 3;
}
nir_shader *nir = spirv_to_nir(spirv->words, spirv->num_words,
spec_entries, num_spec_entries,
- clamp_stage(zs->nir), "main", &spirv_options, &screen->nir_options);
+ clamp_stage(&zs->info), "main", &spirv_options, &screen->nir_options);
assert(nir);
ralloc_free(nir);
free(spec_entries);
mod = zink_shader_spirv_compile(screen, zs, spirv);
/* TODO: determine if there's any reason to cache spirv output? */
- if (zs->nir->info.stage == MESA_SHADER_TESS_CTRL && zs->non_fs.is_generated)
+ if (zs->info.stage == MESA_SHADER_TESS_CTRL && zs->non_fs.is_generated)
zs->spirv = spirv;
else
ralloc_free(spirv);
/* TODO: use a separate mem ctx here for ralloc */
if (!screen->optimal_keys) {
- switch (zs->nir->info.stage) {
+ switch (zs->info.stage) {
case MESA_SHADER_VERTEX: {
uint32_t decomposed_attrs = 0, decomposed_attrs_without_w = 0;
const struct zink_vs_key *vs_key = zink_vs_key(key);
}
}
- switch (zs->nir->info.stage) {
+ switch (zs->info.stage) {
case MESA_SHADER_VERTEX:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
subgroup_options.ballot_bit_size = 32;
subgroup_options.ballot_components = 4;
subgroup_options.lower_subgroup_masks = true;
- if (!(screen->info.subgroup.supportedStages & mesa_to_vk_shader_stage(clamp_stage(nir)))) {
+ if (!(screen->info.subgroup.supportedStages & mesa_to_vk_shader_stage(clamp_stage(&nir->info)))) {
subgroup_options.subgroup_size = 1;
subgroup_options.lower_vote_trivial = true;
}
ztype = ZINK_DESCRIPTOR_TYPE_UBO;
/* buffer 0 is a push descriptor */
var->data.descriptor_set = !!var->data.driver_location;
- var->data.binding = !var->data.driver_location ? clamp_stage(nir) :
+ var->data.binding = !var->data.driver_location ? clamp_stage(&nir->info) :
zink_binding(nir->info.stage,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
var->data.driver_location,
void
zink_shader_free(struct zink_screen *screen, struct zink_shader *shader)
{
- assert(shader->nir->info.stage != MESA_SHADER_COMPUTE);
+ assert(shader->info.stage != MESA_SHADER_COMPUTE);
set_foreach(shader->programs, entry) {
struct zink_gfx_program *prog = (void*)entry->key;
- gl_shader_stage stage = shader->nir->info.stage;
+ gl_shader_stage stage = shader->info.stage;
assert(stage < ZINK_GFX_SHADER_COUNT);
if (!prog->base.removed && prog->stages_present == prog->stages_remaining &&
(stage == MESA_SHADER_FRAGMENT || !shader->non_fs.is_generated)) {
}
zink_gfx_program_reference(screen, &prog, NULL);
}
- if (shader->nir->info.stage == MESA_SHADER_TESS_EVAL &&
+ if (shader->info.stage == MESA_SHADER_TESS_EVAL &&
shader->non_fs.generated_tcs) {
/* automatically destroy generated tcs shaders when tes is destroyed */
zink_shader_free(screen, shader->non_fs.generated_tcs);
}
for (unsigned int i = 0; i < ARRAY_SIZE(shader->non_fs.generated_gs); i++) {
for (int j = 0; j < ARRAY_SIZE(shader->non_fs.generated_gs[0]); j++) {
- if (shader->nir->info.stage != MESA_SHADER_FRAGMENT &&
+ if (shader->info.stage != MESA_SHADER_FRAGMENT &&
shader->non_fs.generated_gs[i][j]) {
/* automatically destroy generated gs shaders when owner is destroyed */
zink_shader_free(screen, shader->non_fs.generated_gs[i][j]);
VkShaderModule
zink_shader_tcs_compile(struct zink_screen *screen, struct zink_shader *zs, unsigned patch_vertices)
{
- assert(zs->nir->info.stage == MESA_SHADER_TESS_CTRL);
+ assert(zs->info.stage == MESA_SHADER_TESS_CTRL);
/* shortcut all the nir passes since we just have to change this one word */
zs->spirv->words[zs->spirv->tcs_vertices_out_word] = patch_vertices;
return zink_shader_spirv_compile(screen, zs, NULL);
unsigned idx, struct zink_descriptor_template *entry, unsigned *entry_idx)
{
int index = shader->bindings[type][idx].index;
- gl_shader_stage stage = shader->nir->info.stage;
+ gl_shader_stage stage = shader->info.stage;
entry->count = shader->bindings[type][idx].size;
switch (shader->bindings[type][idx].type) {
unsigned idx, VkDescriptorUpdateTemplateEntry *entry, unsigned *entry_idx)
{
int index = shader->bindings[type][idx].index;
- gl_shader_stage stage = clamp_stage(shader->nir);
+ gl_shader_stage stage = clamp_stage(&shader->info);
entry->dstArrayElement = 0;
entry->dstBinding = shader->bindings[type][idx].binding;
entry->descriptorCount = shader->bindings[type][idx].size;
else
stages = ((struct zink_gfx_program*)pg)->shaders;
- if (!pg->is_compute && stages[MESA_SHADER_FRAGMENT]->nir->info.fs.uses_fbfetch_output) {
+ if (!pg->is_compute && stages[MESA_SHADER_FRAGMENT]->info.fs.uses_fbfetch_output) {
push_count = 1;
pg->dd.fbfetch = true;
}
if (!shader)
continue;
- gl_shader_stage stage = clamp_stage(shader->nir);
+ gl_shader_stage stage = clamp_stage(&shader->info);
VkShaderStageFlagBits stage_flags = mesa_to_vk_shader_stage(stage);
/* uniform ubos handled in push */
if (shader->has_uniforms) {
/* some sets can have multiple descriptor types: ensure the size arrays for these types are contiguous for creating the pool key */
VkDescriptorPoolSize *sz = &sizes[idx];
VkDescriptorPoolSize sz2[5];
- if (screen->compact_descriptors || (pg->is_compute && stages[0]->nir->info.stage == MESA_SHADER_KERNEL)) {
+ if (screen->compact_descriptors || (pg->is_compute && stages[0]->info.stage == MESA_SHADER_KERNEL)) {
unsigned found = 0;
while (found < num_type_sizes[desc_type]) {
if (sz->descriptorCount) {
{
VkDescriptorSetLayoutBinding bindings[ZINK_DESCRIPTOR_BASE_TYPES * ZINK_MAX_DESCRIPTORS_PER_TYPE];
unsigned num_bindings = 0;
- VkShaderStageFlagBits stage_flags = mesa_to_vk_shader_stage(shader->nir->info.stage);
+ VkShaderStageFlagBits stage_flags = mesa_to_vk_shader_stage(shader->info.stage);
unsigned desc_set_size = shader->has_uniforms;
for (unsigned i = 0; i < ZINK_DESCRIPTOR_BASE_TYPES; i++)
binding->pImmutableSamplers = NULL;
struct zink_descriptor_template *entry = &shader->precompile.db_template[num_bindings];
entry->count = 1;
- entry->offset = offsetof(struct zink_context, di.db.ubos[shader->nir->info.stage][0]);
+ entry->offset = offsetof(struct zink_context, di.db.ubos[shader->info.stage][0]);
entry->stride = sizeof(VkDescriptorAddressInfoEXT);
entry->db_size = screen->info.db_props.robustUniformBufferDescriptorSize;
num_bindings++;
if (shader->bindless)
num_dsl = screen->compact_descriptors ? ZINK_DESCRIPTOR_ALL_TYPES - ZINK_DESCRIPTOR_COMPACT : ZINK_DESCRIPTOR_ALL_TYPES;
if (num_bindings || shader->bindless) {
- dsl[shader->nir->info.stage == MESA_SHADER_FRAGMENT] = shader->precompile.dsl;
+ dsl[shader->info.stage == MESA_SHADER_FRAGMENT] = shader->precompile.dsl;
if (shader->bindless)
dsl[screen->desc_set_id[ZINK_DESCRIPTOR_BINDLESS]] = screen->bindless_layout;
}
bool has_nonseamless, //is nonseamless ext present?
unsigned *inline_size, unsigned *nonseamless_size)
{
- gl_shader_stage stage = zs->nir->info.stage;
+ gl_shader_stage stage = zs->info.stage;
struct zink_shader_key *key = &state->shader_keys.key[stage];
- if (has_inline && ctx && zs->nir->info.num_inlinable_uniforms &&
+ if (has_inline && ctx && zs->info.num_inlinable_uniforms &&
ctx->inlinable_uniforms_valid_mask & BITFIELD64_BIT(stage)) {
if (zs->can_inline && (screen->is_cpu || prog->inlined_variant_count[stage] < ZINK_MAX_INLINED_VARIANTS))
- *inline_size = zs->nir->info.num_inlinable_uniforms;
+ *inline_size = zs->info.num_inlinable_uniforms;
else
key->inline_uniforms = false;
}
zink_gfx_program_update(struct zink_context *ctx)
{
if (ctx->last_vertex_stage_dirty) {
- gl_shader_stage pstage = ctx->last_vertex_stage->nir->info.stage;
+ gl_shader_stage pstage = ctx->last_vertex_stage->info.stage;
ctx->dirty_gfx_stages |= BITFIELD_BIT(pstage);
memcpy(&ctx->gfx_pipeline_state.shader_keys.key[pstage].key.vs_base,
&ctx->gfx_pipeline_state.shader_keys.last_vertex.key.vs_base,
const union zink_shader_key_optimal *optimal_key = (union zink_shader_key_optimal*)&prog->last_variant_hash;
if (ctx->gfx_pipeline_state.shader_keys_optimal.key.vs_bits != optimal_key->vs_bits) {
assert(!prog->is_separable);
- bool changed = update_gfx_shader_module_optimal(ctx, prog, ctx->last_vertex_stage->nir->info.stage);
+ bool changed = update_gfx_shader_module_optimal(ctx, prog, ctx->last_vertex_stage->info.stage);
ctx->gfx_pipeline_state.modules_changed |= changed;
}
const bool shadow_needs_shader_swizzle = optimal_key->fs.shadow_needs_shader_swizzle && (ctx->dirty_gfx_stages & BITFIELD_BIT(MESA_SHADER_FRAGMENT));
ASSERTED bool check_robustness = screen->driver_workarounds.lower_robustImageAccess2 && (ctx->flags & PIPE_CONTEXT_ROBUST_BUFFER_ACCESS);
assert(zink_cs_key(key)->robust_access == check_robustness);
- if (ctx && zs->nir->info.num_inlinable_uniforms &&
+ if (ctx && zs->info.num_inlinable_uniforms &&
ctx->inlinable_uniforms_valid_mask & BITFIELD64_BIT(MESA_SHADER_COMPUTE)) {
if (screen->is_cpu || comp->inlined_variant_count < ZINK_MAX_INLINED_VARIANTS)
- inline_size = zs->nir->info.num_inlinable_uniforms;
+ inline_size = zs->info.num_inlinable_uniforms;
else
key->inline_uniforms = false;
}
_mesa_hash_table_init(&prog->pipelines[r][i], prog, NULL, zink_get_gfx_pipeline_eq_func(screen, prog));
/* only need first 3/4 for point/line/tri/patch */
if (screen->info.have_EXT_extended_dynamic_state &&
- i == (prog->last_vertex_stage->nir->info.stage == MESA_SHADER_TESS_EVAL ? 4 : 3))
+ i == (prog->last_vertex_stage->info.stage == MESA_SHADER_TESS_EVAL ? 4 : 3))
break;
}
}
_mesa_hash_table_init(&prog->pipelines[r][i], prog, NULL, zink_get_gfx_pipeline_eq_func(screen, prog));
/* only need first 3/4 for point/line/tri/patch */
if (screen->info.have_EXT_extended_dynamic_state &&
- i == (prog->last_vertex_stage->nir->info.stage == MESA_SHADER_TESS_EVAL ? 4 : 3))
+ i == (prog->last_vertex_stage->info.stage == MESA_SHADER_TESS_EVAL ? 4 : 3))
break;
}
}
case ZINK_DESCRIPTOR_TYPE_SSBO:
return zs->ssbos_used;
case ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW:
- return BITSET_TEST_RANGE(zs->nir->info.textures_used, 0, PIPE_MAX_SAMPLERS - 1);
+ return BITSET_TEST_RANGE(zs->info.textures_used, 0, PIPE_MAX_SAMPLERS - 1);
case ZINK_DESCRIPTOR_TYPE_IMAGE:
- return BITSET_TEST_RANGE(zs->nir->info.images_used, 0, PIPE_MAX_SAMPLERS - 1);
+ return BITSET_TEST_RANGE(zs->info.images_used, 0, PIPE_MAX_SAMPLERS - 1);
default:
unreachable("unknown descriptor type!");
}
static void
bind_gfx_stage(struct zink_context *ctx, gl_shader_stage stage, struct zink_shader *shader)
{
- if (shader && shader->nir->info.num_inlinable_uniforms)
+ if (shader && shader->info.num_inlinable_uniforms)
ctx->shader_has_inlinable_uniforms_mask |= 1 << stage;
else
ctx->shader_has_inlinable_uniforms_mask &= ~(1 << stage);
static enum pipe_prim_type
update_rast_prim(struct zink_shader *shader)
{
- struct shader_info *info = &shader->nir->info;
+ struct shader_info *info = &shader->info;
if (info->stage == MESA_SHADER_GEOMETRY)
return gs_output_to_reduced_prim_type(info);
else if (info->stage == MESA_SHADER_TESS_EVAL) {
if (prev_shader && stage < MESA_SHADER_GEOMETRY)
unbind_generated_gs(ctx, stage, prev_shader);
- gl_shader_stage old = ctx->last_vertex_stage ? ctx->last_vertex_stage->nir->info.stage : MESA_SHADER_STAGES;
+ gl_shader_stage old = ctx->last_vertex_stage ? ctx->last_vertex_stage->info.stage : MESA_SHADER_STAGES;
if (ctx->gfx_stages[MESA_SHADER_GEOMETRY])
ctx->last_vertex_stage = ctx->gfx_stages[MESA_SHADER_GEOMETRY];
else if (ctx->gfx_stages[MESA_SHADER_TESS_EVAL])
ctx->last_vertex_stage = ctx->gfx_stages[MESA_SHADER_TESS_EVAL];
else
ctx->last_vertex_stage = ctx->gfx_stages[MESA_SHADER_VERTEX];
- gl_shader_stage current = ctx->last_vertex_stage ? ctx->last_vertex_stage->nir->info.stage : MESA_SHADER_VERTEX;
+ gl_shader_stage current = ctx->last_vertex_stage ? ctx->last_vertex_stage->info.stage : MESA_SHADER_VERTEX;
/* update rast_prim */
ctx->gfx_pipeline_state.shader_rast_prim =
struct zink_screen *screen = zink_screen(ctx->base.screen);
/* number of enabled viewports is based on whether last vertex stage writes viewport index */
if (ctx->last_vertex_stage) {
- if (ctx->last_vertex_stage->nir->info.outputs_written & (VARYING_BIT_VIEWPORT | VARYING_BIT_VIEWPORT_MASK))
+ if (ctx->last_vertex_stage->info.outputs_written & (VARYING_BIT_VIEWPORT | VARYING_BIT_VIEWPORT_MASK))
ctx->vp_state.num_viewports = MIN2(screen->info.props.limits.maxViewports, PIPE_MAX_VIEWPORTS);
else
ctx->vp_state.num_viewports = 1;
bind_last_vertex_stage(ctx, MESA_SHADER_VERTEX, prev_shader);
if (cso) {
struct zink_shader *zs = cso;
- ctx->shader_reads_drawid = BITSET_TEST(zs->nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID);
- ctx->shader_reads_basevertex = BITSET_TEST(zs->nir->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX);
+ ctx->shader_reads_drawid = BITSET_TEST(zs->info.system_values_read, SYSTEM_VALUE_DRAW_ID);
+ ctx->shader_reads_basevertex = BITSET_TEST(zs->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX);
} else {
ctx->shader_reads_drawid = false;
ctx->shader_reads_basevertex = false;
{
if (!ctx->gfx_stages[MESA_SHADER_FRAGMENT])
return;
- nir_shader *nir = ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir;
- if (nir->info.outputs_written & (1 << FRAG_RESULT_SAMPLE_MASK)) {
+ shader_info *info = &ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info;
+ if (info->outputs_written & (1 << FRAG_RESULT_SAMPLE_MASK)) {
bool samples = zink_get_fs_base_key(ctx)->samples;
if (samples != (ctx->fb_state.samples > 1))
zink_set_fs_base_key(ctx)->samples = ctx->fb_state.samples > 1;
bind_gfx_stage(ctx, MESA_SHADER_FRAGMENT, cso);
ctx->fbfetch_outputs = 0;
if (cso) {
- nir_shader *nir = ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir;
- if (nir->info.fs.uses_fbfetch_output) {
+ shader_info *info = &ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info;
+ if (info->fs.uses_fbfetch_output) {
nir_foreach_shader_out_variable(var, ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir) {
if (var->data.fb_fetch_output)
ctx->fbfetch_outputs |= BITFIELD_BIT(var->data.location - FRAG_RESULT_DATA0);
}
zink_update_fs_key_samples(ctx);
if (zink_screen(pctx->screen)->info.have_EXT_rasterization_order_attachment_access) {
- if (ctx->gfx_pipeline_state.rast_attachment_order != nir->info.fs.uses_fbfetch_output)
+ if (ctx->gfx_pipeline_state.rast_attachment_order != info->fs.uses_fbfetch_output)
ctx->gfx_pipeline_state.dirty = true;
- ctx->gfx_pipeline_state.rast_attachment_order = nir->info.fs.uses_fbfetch_output;
+ ctx->gfx_pipeline_state.rast_attachment_order = info->fs.uses_fbfetch_output;
}
zink_set_zs_needs_shader_swizzle_key(ctx, MESA_SHADER_FRAGMENT, false);
if (shadow_mask != ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask &&
zs->precompile.mod = zink_shader_compile_separate(screen, zs);
zink_descriptor_shader_init(screen, zs);
VkShaderModule mods[ZINK_GFX_SHADER_COUNT] = {0};
- mods[zs->nir->info.stage] = zs->precompile.mod;
+ mods[zs->info.stage] = zs->precompile.mod;
zs->precompile.gpl = zink_create_gfx_pipeline_separate(screen, mods, zs->precompile.layout);
}
if (!shaders[MESA_SHADER_VERTEX] || !shaders[MESA_SHADER_FRAGMENT]) {
if (shaders[MESA_SHADER_VERTEX] || shaders[MESA_SHADER_FRAGMENT]) {
struct zink_shader *zs = shaders[MESA_SHADER_VERTEX] ? shaders[MESA_SHADER_VERTEX] : shaders[MESA_SHADER_FRAGMENT];
- if (zs->nir->info.separate_shader && !zs->precompile.mod && util_queue_fence_is_signalled(&zs->precompile.fence) &&
+ if (zs->info.separate_shader && !zs->precompile.mod && util_queue_fence_is_signalled(&zs->precompile.fence) &&
zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB &&
/* sample shading can't precompile */
- (!shaders[MESA_SHADER_FRAGMENT] || !zs->nir->info.fs.uses_sample_shading))
+ (!shaders[MESA_SHADER_FRAGMENT] || !zs->info.fs.uses_sample_shading))
util_queue_add_job(&zink_screen(pctx->screen)->cache_get_thread, zs, &zs->precompile.fence, precompile_separate_shader_job, NULL, 0);
}
return;
zink_rast_prim_for_pipe(ctx->gfx_pipeline_state.rast_prim);
//when using transform feedback primitives must be tessellated
- lower_filled_quad |= lower_quad_prim && ctx->gfx_stages[prev_vertex_stage]->nir->info.has_transform_feedback_varyings;
+ lower_filled_quad |= lower_quad_prim && ctx->gfx_stages[prev_vertex_stage]->info.has_transform_feedback_varyings;
if (!ctx->gfx_stages[MESA_SHADER_GEOMETRY] ||
- (ctx->gfx_stages[MESA_SHADER_GEOMETRY]->nir->info.gs.input_primitive != ctx->gfx_pipeline_state.gfx_prim_mode)) {
+ (ctx->gfx_stages[MESA_SHADER_GEOMETRY]->info.gs.input_primitive != ctx->gfx_pipeline_state.gfx_prim_mode)) {
if (!ctx->gfx_stages[prev_vertex_stage]->non_fs.generated_gs[ctx->gfx_pipeline_state.gfx_prim_mode][zink_prim_type]) {
nir_shader *nir;