pvr: Write immutable descriptor words in vkAllocateDescriptorSets().

Signed-off-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16883>
This commit is contained in:
Karmjit Mahil 2022-02-25 17:06:38 +00:00 committed by Marge Bot
parent 81077a4c7d
commit 61db3154b4
4 changed files with 56 additions and 14 deletions

View File

@ -119,4 +119,14 @@ pvr_ta_objtype(VkPrimitiveTopology topology)
}
}
/******************************************************************************
TEXSTATE
******************************************************************************/
static inline enum PVRX(TEXSTATE_CMP_MODE) pvr_texstate_cmpmode(VkCompareOp op)
{
/* enum values are identical, so we can just cast the input directly. */
return (enum PVRX(TEXSTATE_CMP_MODE))op;
}
#endif /* PVR_CSB_ENUM_HELPERS_H */

View File

@ -88,9 +88,9 @@ static void pvr_descriptor_size_info_init(
*/
static const struct pvr_descriptor_size_info template_size_infos[] = {
/* VK_DESCRIPTOR_TYPE_SAMPLER */
{ 4, 0, 4 },
{ PVR_SAMPLER_DESCRIPTOR_SIZE, 0, 4 },
/* VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER */
{ 8, UINT_MAX, 4 },
{ PVR_SAMPLER_DESCRIPTOR_SIZE + 4, UINT_MAX, 4 },
/* VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE */
{ 4, UINT_MAX, 4 },
/* VK_DESCRIPTOR_TYPE_STORAGE_IMAGE */
@ -1125,13 +1125,6 @@ static uint16_t pvr_get_descriptor_secondary_offset(
return (uint16_t)offset;
}
static void pvr_write_sampler_descriptor(uint32_t *primary,
const struct pvr_sampler *sampler)
{
/* TODO: Implement based on WriteSamplerDescriptor. */
pvr_finishme("Implement after vkCreateSampler API.");
}
#define PVR_MAX_DESCRIPTOR_MEM_SIZE_IN_DWORDS (4 * 1024)
static VkResult
@ -1162,6 +1155,7 @@ pvr_descriptor_set_create(struct pvr_device *device,
* for max descriptors supported by pool as done by v3dv. Also check the
* possibility if this can be removed from here and done on need basis.
*/
if (layout->binding_count > 0) {
const uint32_t cache_line_size =
rogue_get_slc_cache_line_size(&device->pdevice->dev_info);
@ -1209,9 +1203,9 @@ pvr_descriptor_set_create(struct pvr_device *device,
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset_in_dwords += 4;
pvr_write_sampler_descriptor(map +
offset_in_dwords * sizeof(uint32_t),
sampler);
memcpy((uint8_t *)map + offset_in_dwords * sizeof(uint32_t),
sampler->descriptor.words,
sizeof(sampler->descriptor.words));
}
}
}

View File

@ -41,6 +41,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#include "pvr_csb.h"
#include "pvr_csb_enum_helpers.h"
#include "pvr_device_info.h"
#include "pvr_job_render.h"
#include "pvr_limits.h"
@ -2082,6 +2083,9 @@ VkResult pvr_CreateSampler(VkDevice _device,
float min_lod;
float max_lod;
STATIC_ASSERT(sizeof(((union pvr_sampler_descriptor *)NULL)->data) ==
sizeof(((union pvr_sampler_descriptor *)NULL)->words));
sampler = vk_object_alloc(&device->vk,
pAllocator,
sizeof(*sampler),
@ -2115,7 +2119,18 @@ VkResult pvr_CreateSampler(VkDevice _device,
}
}
pvr_csb_pack (&sampler->sampler_word, TEXSTATE_SAMPLER, word) {
if (pCreateInfo->compareEnable) {
sampler->descriptor.data.compare_op =
(uint32_t)pvr_texstate_cmpmode(pCreateInfo->compareOp);
} else {
sampler->descriptor.data.compare_op =
(uint32_t)pvr_texstate_cmpmode(VK_COMPARE_OP_NEVER);
}
sampler->descriptor.data.word3 = 0;
pvr_csb_pack (&sampler->descriptor.data.sampler_word,
TEXSTATE_SAMPLER,
word) {
const struct pvr_device_info *dev_info = &device->pdevice->dev_info;
const float lod_clamp_max = (float)PVRX(TEXSTATE_CLAMP_MAX) /
(1 << PVRX(TEXSTATE_CLAMP_FRACTIONAL_BITS));
@ -2139,6 +2154,13 @@ VkResult pvr_CreateSampler(VkDevice _device,
word.addrmode_w =
pvr_sampler_get_hw_addr_mode_from_vk(pCreateInfo->addressModeW);
/* TODO: Figure out defines for these. */
if (word.addrmode_u == PVRX(TEXSTATE_ADDRMODE_FLIP))
sampler->descriptor.data.word3 |= 0x40000000;
if (word.addrmode_v == PVRX(TEXSTATE_ADDRMODE_FLIP))
sampler->descriptor.data.word3 |= 0x20000000;
/* The Vulkan 1.0.205 spec says:
*
* The absolute value of mipLodBias must be less than or equal to

View File

@ -74,6 +74,8 @@
#define PVR_WORKGROUP_DIMENSIONS 3U
#define PVR_SAMPLER_DESCRIPTOR_SIZE 4U
#define PVR_STATE_PBE_DWORDS 2U
#define PVR_PIPELINE_LAYOUT_SUPPORTED_DESCRIPTOR_TYPE_COUNT \
@ -355,10 +357,24 @@ struct pvr_image_view {
uint64_t texture_state[PVR_TEXTURE_STATE_MAX_ENUM][2];
};
union pvr_sampler_descriptor {
uint32_t words[PVR_SAMPLER_DESCRIPTOR_SIZE];
struct {
/* Packed PVRX(TEXSTATE_SAMPLER). */
uint64_t sampler_word;
uint32_t compare_op;
/* TODO: Figure out what this word is for and rename.
* Sampler state word 1?
*/
uint32_t word3;
} data;
};
struct pvr_sampler {
struct vk_object_base base;
uint64_t sampler_word;
union pvr_sampler_descriptor descriptor;
};
struct pvr_descriptor_size_info {