gallivm/sample: add some num_samples vs level zero only support
This just checks the level zero only is set for multisample stuff. I tried using asserts, but there are paths due to precompilation that won't get hit, but do get compiled. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25398>
This commit is contained in:
@@ -605,6 +605,7 @@ lp_bld_llvm_image_soa_emit_size_query(const struct lp_build_image_soa *base,
|
||||
.format = format,
|
||||
.res_format = format,
|
||||
.target = params->target,
|
||||
.level_zero_only = params->ms,
|
||||
};
|
||||
|
||||
lp_build_size_query_soa(gallivm, &state, &image->dynamic_state.base, params);
|
||||
|
||||
@@ -1821,7 +1821,8 @@ visit_image_size(struct lp_build_nir_context *bld_base,
|
||||
params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr),
|
||||
nir_intrinsic_image_array(instr));
|
||||
params.sizes_out = result;
|
||||
|
||||
params.ms = nir_intrinsic_image_dim(instr) == GLSL_SAMPLER_DIM_MS ||
|
||||
nir_intrinsic_image_dim(instr) == GLSL_SAMPLER_DIM_SUBPASS_MS;
|
||||
params.format = nir_intrinsic_format(instr);
|
||||
|
||||
bld_base->image_size(bld_base, ¶ms);
|
||||
@@ -1840,6 +1841,8 @@ visit_image_samples(struct lp_build_nir_context *bld_base,
|
||||
params.target = glsl_sampler_to_pipe(nir_intrinsic_image_dim(instr),
|
||||
nir_intrinsic_image_array(instr));
|
||||
params.sizes_out = result;
|
||||
params.ms = nir_intrinsic_image_dim(instr) == GLSL_SAMPLER_DIM_MS ||
|
||||
nir_intrinsic_image_dim(instr) == GLSL_SAMPLER_DIM_SUBPASS_MS;
|
||||
params.samples_only = true;
|
||||
|
||||
params.format = nir_intrinsic_format(instr);
|
||||
@@ -2369,6 +2372,8 @@ visit_txs(struct lp_build_nir_context *bld_base, nir_tex_instr *instr)
|
||||
params.sizes_out = sizes_out;
|
||||
params.samples_only = (instr->op == nir_texop_texture_samples);
|
||||
params.texture_unit_offset = texture_unit_offset;
|
||||
params.ms = instr->sampler_dim == GLSL_SAMPLER_DIM_MS ||
|
||||
instr->sampler_dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
|
||||
|
||||
if (instr->op == nir_texop_query_levels)
|
||||
params.explicit_lod = bld_base->uint_bld.zero;
|
||||
|
||||
@@ -166,7 +166,7 @@ lp_sampler_static_texture_state_image(struct lp_static_texture_state *state,
|
||||
state->pot_width = util_is_power_of_two_or_zero(resource->width0);
|
||||
state->pot_height = util_is_power_of_two_or_zero(resource->height0);
|
||||
state->pot_depth = util_is_power_of_two_or_zero(resource->depth0);
|
||||
state->level_zero_only = 0;
|
||||
state->level_zero_only = view->u.tex.level == 0;
|
||||
|
||||
/*
|
||||
* the layer / element / level parameters are all either dynamic
|
||||
|
||||
@@ -136,6 +136,7 @@ struct lp_sampler_size_query_params
|
||||
LLVMValueRef resources_ptr;
|
||||
bool is_sviewinfo;
|
||||
bool samples_only;
|
||||
bool ms;
|
||||
enum lp_sampler_lod_property lod_property;
|
||||
LLVMValueRef explicit_lod;
|
||||
LLVMValueRef *sizes_out;
|
||||
|
||||
@@ -3243,7 +3243,7 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
|
||||
lp_build_get_mip_offsets(bld, ilevel));
|
||||
}
|
||||
|
||||
if (bld->fetch_ms) {
|
||||
if (bld->fetch_ms && bld->static_texture_state->level_zero_only) {
|
||||
LLVMValueRef num_samples = bld->dynamic_state->num_samples(bld->gallivm,
|
||||
bld->resources_type,
|
||||
bld->resources_ptr,
|
||||
@@ -4496,14 +4496,22 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
|
||||
lp_build_context_init(&bld_int_vec4, gallivm, lp_type_int_vec(32, 128));
|
||||
|
||||
if (params->samples_only) {
|
||||
LLVMValueRef num_samples;
|
||||
|
||||
if (params->ms && static_state->level_zero_only) {
|
||||
/* multisample never has levels. */
|
||||
num_samples = dynamic_state->num_samples(gallivm,
|
||||
resources_type,
|
||||
resources_ptr,
|
||||
texture_unit,
|
||||
texture_unit_offset);
|
||||
} else {
|
||||
num_samples = lp_build_const_int32(gallivm, 0);
|
||||
}
|
||||
params->sizes_out[0] =
|
||||
lp_build_broadcast(gallivm,
|
||||
lp_build_vec_type(gallivm, params->int_type),
|
||||
dynamic_state->num_samples(gallivm,
|
||||
resources_type,
|
||||
resources_ptr,
|
||||
texture_unit,
|
||||
texture_unit_offset));
|
||||
num_samples);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4925,7 +4933,7 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
|
||||
x, y, z, row_stride_vec, img_stride_vec,
|
||||
&offset, &i, &j);
|
||||
|
||||
if (params->ms_index) {
|
||||
if (params->ms_index && static_texture_state->level_zero_only) {
|
||||
LLVMValueRef num_samples = dynamic_state->num_samples(gallivm,
|
||||
params->resources_type,
|
||||
params->resources_ptr,
|
||||
|
||||
@@ -526,6 +526,7 @@ compile_size_function(struct llvmpipe_context *ctx, struct lp_static_texture_sta
|
||||
.resources_type = cs.jit_resources_type,
|
||||
.is_sviewinfo = true,
|
||||
.samples_only = samples,
|
||||
.ms = samples,
|
||||
};
|
||||
|
||||
if (params.target == PIPE_TEXTURE_1D)
|
||||
|
||||
Reference in New Issue
Block a user