gallivm/lp: move sampler index around to reduce struct
I'm not sure this is 100% correct, but it does reduce the struct size to 256 which is conformant Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25398>
This commit is contained in:
@@ -201,7 +201,7 @@ lp_bld_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base
|
||||
} else {
|
||||
sampler_desc_ptr = lp_llvm_descriptor_base(gallivm, consts, params->sampler_resource, LP_MAX_TGSI_CONST_BUFFERS);
|
||||
|
||||
LLVMValueRef sampler_index_offset = lp_build_const_int64(gallivm, offsetof(struct lp_descriptor, sampler_index));
|
||||
LLVMValueRef sampler_index_offset = lp_build_const_int64(gallivm, offsetof(struct lp_descriptor, texture.sampler_index));
|
||||
LLVMValueRef sampler_index_ptr = LLVMBuildAdd(builder, sampler_desc_ptr, sampler_index_offset, "");
|
||||
|
||||
LLVMTypeRef sampler_index_type = LLVMInt32TypeInContext(gallivm->context);
|
||||
|
||||
@@ -146,6 +146,7 @@ lp_build_create_jit_texture_type(struct gallivm_state *gallivm)
|
||||
LLVMTypeRef elem_types[LP_JIT_TEXTURE_NUM_FIELDS];
|
||||
|
||||
/* struct lp_jit_texture */
|
||||
elem_types[LP_JIT_SAMPLER_INDEX_DUMMY] =
|
||||
elem_types[LP_JIT_TEXTURE_WIDTH] = LLVMInt32TypeInContext(lc);
|
||||
elem_types[LP_JIT_TEXTURE_HEIGHT] =
|
||||
elem_types[LP_JIT_TEXTURE_DEPTH] = LLVMInt16TypeInContext(lc);
|
||||
|
||||
@@ -73,6 +73,7 @@ struct lp_jit_texture
|
||||
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
|
||||
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
|
||||
uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]; /* sample stride is in mip_offsets[15] */
|
||||
uint32_t sampler_index;
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -85,6 +86,7 @@ enum {
|
||||
LP_JIT_TEXTURE_ROW_STRIDE,
|
||||
LP_JIT_TEXTURE_IMG_STRIDE,
|
||||
LP_JIT_TEXTURE_MIP_OFFSETS,
|
||||
LP_JIT_SAMPLER_INDEX_DUMMY,
|
||||
LP_JIT_TEXTURE_NUM_FIELDS /* number of fields above */
|
||||
};
|
||||
|
||||
@@ -239,7 +241,6 @@ struct lp_descriptor {
|
||||
/* Store sample/image functions in the same location since some d3d12 games
|
||||
* rely on mismatched descriptor types with null descriptors.
|
||||
*/
|
||||
uint32_t sampler_index;
|
||||
void *functions;
|
||||
};
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_UpdateDescriptorSets(
|
||||
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[didx + k].sampler = sampler->desc.sampler;
|
||||
desc[didx + k].sampler_index = sampler->desc.sampler_index;
|
||||
desc[didx + k].texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,13 +492,13 @@ VKAPI_ATTR void VKAPI_CALL lvp_UpdateDescriptorSets(
|
||||
|
||||
for (unsigned p = 0; p < plane_count; p++) {
|
||||
desc[didx + p].sampler = sampler->desc.sampler;
|
||||
desc[didx + p].sampler_index = sampler->desc.sampler_index;
|
||||
desc[didx + p].texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[didx + k].functions = device->null_texture_handle->functions;
|
||||
desc[didx + k].sampler_index = 0;
|
||||
desc[didx + k].texture.sampler_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +519,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_UpdateDescriptorSets(
|
||||
} else {
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[didx + k].functions = device->null_texture_handle->functions;
|
||||
desc[didx + k].sampler_index = 0;
|
||||
desc[didx + k].texture.sampler_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +554,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_UpdateDescriptorSets(
|
||||
desc[j].functions = bview->texture_handle->functions;
|
||||
} else {
|
||||
desc[j].functions = device->null_texture_handle->functions;
|
||||
desc[j].sampler_index = 0;
|
||||
desc[j].texture.sampler_index = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -851,7 +851,7 @@ lvp_descriptor_set_update_with_template(VkDevice _device, VkDescriptorSet descri
|
||||
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[idx + k].sampler = sampler->desc.sampler;
|
||||
desc[idx + k].sampler_index = sampler->desc.sampler_index;
|
||||
desc[idx + k].texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -870,13 +870,13 @@ lvp_descriptor_set_update_with_template(VkDevice _device, VkDescriptorSet descri
|
||||
|
||||
for (unsigned p = 0; p < iview->plane_count; p++) {
|
||||
desc[idx + p].sampler = sampler->desc.sampler;
|
||||
desc[idx + p].sampler_index = sampler->desc.sampler_index;
|
||||
desc[idx + p].texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[idx + k].functions = device->null_texture_handle->functions;
|
||||
desc[idx + k].sampler_index = 0;
|
||||
desc[idx + k].texture.sampler_index = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -893,7 +893,7 @@ lvp_descriptor_set_update_with_template(VkDevice _device, VkDescriptorSet descri
|
||||
} else {
|
||||
for (unsigned k = 0; k < bind_layout->stride; k++) {
|
||||
desc[idx + k].functions = device->null_texture_handle->functions;
|
||||
desc[idx + k].sampler_index = 0;
|
||||
desc[idx + k].texture.sampler_index = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -923,7 +923,7 @@ lvp_descriptor_set_update_with_template(VkDevice _device, VkDescriptorSet descri
|
||||
desc[idx].functions = bview->texture_handle->functions;
|
||||
} else {
|
||||
desc[j].functions = device->null_texture_handle->functions;
|
||||
desc[j].sampler_index = 0;
|
||||
desc[j].texture.sampler_index = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1057,10 +1057,10 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetDescriptorEXT(
|
||||
if (pCreateInfo->data.pSampler) {
|
||||
LVP_FROM_HANDLE(lvp_sampler, sampler, pCreateInfo->data.pSampler[0]);
|
||||
desc->sampler = sampler->desc.sampler;
|
||||
desc->sampler_index = sampler->desc.sampler_index;
|
||||
desc->texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
} else {
|
||||
lp_jit_sampler_from_pipe(&desc->sampler, &sampler);
|
||||
desc->sampler_index = 0;
|
||||
desc->texture.sampler_index = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1076,14 +1076,14 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetDescriptorEXT(
|
||||
if (info->sampler) {
|
||||
LVP_FROM_HANDLE(lvp_sampler, sampler, info->sampler);
|
||||
desc->sampler = sampler->desc.sampler;
|
||||
desc->sampler_index = sampler->desc.sampler_index;
|
||||
desc->texture.sampler_index = sampler->desc.texture.sampler_index;
|
||||
} else {
|
||||
lp_jit_sampler_from_pipe(&desc->sampler, &sampler);
|
||||
desc->sampler_index = 0;
|
||||
desc->texture.sampler_index = 0;
|
||||
}
|
||||
} else {
|
||||
desc->functions = device->null_texture_handle->functions;
|
||||
desc->sampler_index = 0;
|
||||
desc->texture.sampler_index = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1096,7 +1096,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetDescriptorEXT(
|
||||
desc->functions = iview->planes[0].texture_handle->functions;
|
||||
} else {
|
||||
desc->functions = device->null_texture_handle->functions;
|
||||
desc->sampler_index = 0;
|
||||
desc->texture.sampler_index = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1121,7 +1121,7 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetDescriptorEXT(
|
||||
desc->functions = get_texture_handle_bda(device, bda, pformat).functions;
|
||||
} else {
|
||||
desc->functions = device->null_texture_handle->functions;
|
||||
desc->sampler_index = 0;
|
||||
desc->texture.sampler_index = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2252,7 +2252,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSampler(
|
||||
simple_mtx_unlock(&device->queue.lock);
|
||||
|
||||
lp_jit_sampler_from_pipe(&sampler->desc.sampler, &state);
|
||||
sampler->desc.sampler_index = sampler->texture_handle->sampler_index;
|
||||
sampler->desc.texture.sampler_index = sampler->texture_handle->sampler_index;
|
||||
|
||||
*pSampler = lvp_sampler_to_handle(sampler);
|
||||
|
||||
|
||||
@@ -4097,7 +4097,7 @@ bind_db_samplers(struct rendering_state *state, enum lvp_pipeline_type pipeline_
|
||||
if (bind_layout->immutable_samplers[sampler_index]) {
|
||||
struct lp_descriptor *immutable_desc = &bind_layout->immutable_samplers[sampler_index]->desc;
|
||||
desc[sampler_index].sampler = immutable_desc->sampler;
|
||||
desc[sampler_index].sampler_index = immutable_desc->sampler_index;
|
||||
desc[sampler_index].texture.sampler_index = immutable_desc->texture.sampler_index;
|
||||
u_foreach_bit(stage, set_layout->shader_stages)
|
||||
did_update |= BITFIELD_BIT(vk_to_mesa_shader_stage(1<<stage));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user