#include <inttypes.h>
#include <stdint.h>
+/**
+ * \brief Convert dwords to bytes.
+ *
+ * Throughout the code base we keep sizes in dwords (e.g. code_size and
+ * data_size returned by the pds api) and in some cases we need to convert those
+ * to be in bytes.
+ *
+ * This macro makes the conversion more obvious.
+ */
+/* clang-format off */
+#define PVR_DW_TO_BYTES(_value) ((_value) * 4)
+/* clang-format on */
+
/*****************************************************************************
Device virtual addresses
*****************************************************************************/
#include "pvr_rogue_pds_defs.h"
#include "pvr_rogue_pds_disasm.h"
#include "pvr_rogue_pds_encode.h"
+#include "pvr_types.h"
#include "util/log.h"
#include "util/macros.h"
addr_literal_buffer_entry->type =
PVR_PDS_CONST_MAP_ENTRY_TYPE_ADDR_LITERAL_BUFFER;
- addr_literal_buffer_entry->size = size_in_dwords * sizeof(uint32_t);
+ addr_literal_buffer_entry->size = PVR_DW_TO_BYTES(size_in_dwords);
addr_literal_buffer_entry->const_offset = next_const64 * 2;
for (unsigned int i = 0; i < input_program->addr_literal_count; i++) {
pvr_clear_needs_rt_id_output(dev_info, rect_count, rects);
/* 4 because we're expecting the USC to output X, Y, Z, and W. */
- vs_output_size_in_bytes = 4 * sizeof(uint32_t);
+ vs_output_size_in_bytes = PVR_DW_TO_BYTES(4);
if (vs_has_rt_id_output)
- vs_output_size_in_bytes += sizeof(uint32_t);
+ vs_output_size_in_bytes += PVR_DW_TO_BYTES(1);
for (uint32_t i = 0; i < attachment_count; i++) {
const VkClearAttachment *attachment = &attachments[i];
#include "pvr_private.h"
#include "pvr_shader_factory.h"
#include "pvr_static_shaders.h"
+#include "pvr_types.h"
#include "vk_alloc.h"
#include "vk_log.h"
result = pvr_bo_alloc(device,
device->heaps.general_heap,
- dword_count * sizeof(uint32_t),
+ PVR_DW_TO_BYTES(dword_count),
cache_line_size,
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pvr_bo);
pvr_pds_set_sizes_pixel_shader_uniform_texture_code(&texture_pds_program);
pds_texture_program_offsets[offset_idx] = alloc_size;
- alloc_size +=
- ALIGN_POT(texture_pds_program.code_size * 4, pds_prog_alignment);
+ alloc_size += ALIGN_POT(PVR_DW_TO_BYTES(texture_pds_program.code_size),
+ pds_prog_alignment);
/* Pixel program to load fragment shader. */
program_size = pixel_shader_pds_program.code_size +
pixel_shader_pds_program.data_size;
- program_size *= sizeof(uint32_t);
+ program_size = PVR_DW_TO_BYTES(program_size);
pds_pixel_program_offsets[offset_idx] = alloc_size;
alloc_size += ALIGN_POT(program_size, pds_prog_alignment);
pvr_pds_vertex_shader(program, NULL, PDS_GENERATE_SIZES, dev_info);
staging_buffer_size =
- (program->code_size + program->data_size) * sizeof(*staging_buffer);
+ PVR_DW_TO_BYTES(program->code_size + program->data_size);
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
pvr_pds_vertex_shader(program, NULL, PDS_GENERATE_SIZES, dev_info);
- staging_buffer_size = program->data_size * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program->data_size);
staging_buffer = vk_alloc(&cmd_buffer->device->vk.alloc,
staging_buffer_size,
pvr_pds_vertex_shader(program, NULL, PDS_GENERATE_SIZES, dev_info);
- staging_buffer_size = program->code_size * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program->code_size);
staging_buffer = vk_alloc(&cmd_buffer->device->vk.alloc,
staging_buffer_size,
DIV_ROUND_UP(temps,
PVRX(VDMCTRL_VDM_STATE5_VS_PDS_TEMP_SIZE_UNIT_SIZE));
state5.vs_pds_data_size =
- DIV_ROUND_UP(program->data_size << 2,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(program->data_size),
PVRX(VDMCTRL_VDM_STATE5_VS_PDS_DATA_SIZE_UNIT_SIZE));
}
stream += pvr_cmd_length(VDMCTRL_VDM_STATE5);
.num_emit_word_pairs = 0,
};
const uint32_t staging_buffer_size =
- cmd_buffer->device->pixel_event_data_size_in_dwords * sizeof(uint32_t);
+ PVR_DW_TO_BYTES(cmd_buffer->device->pixel_event_data_size_in_dwords);
const VkAllocationCallbacks *const allocator = &cmd_buffer->vk.pool->alloc;
struct pvr_device *const device = cmd_buffer->device;
struct util_dynarray eot_program_bin;
pvr_pds_set_sizes_pixel_shader_sa_texture_data(&program, dev_info);
- staging_buffer_size = program.data_size * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.data_size);
staging_buffer = vk_alloc(&cmd_buffer->vk.pool->alloc,
staging_buffer_size,
.usc_unified_size = 0U,
.pds_temp_size = 0U,
.pds_data_size =
- DIV_ROUND_UP(program->data_size << 2,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(program->data_size),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE)),
.usc_target = PVRX(CDMCTRL_USC_TARGET_ALL),
.is_fence = false,
.usc_unified_size = 0U,
.pds_temp_size = 0U,
.pds_data_size =
- DIV_ROUND_UP(program->data_size << 2,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(program->data_size),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE)),
.usc_target = PVRX(CDMCTRL_USC_TARGET_ANY),
.is_fence = true,
struct pvr_bo *pvr_bo;
VkResult result;
- result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
- cmd_buffer->device->heaps.pds_heap,
- pds_info->data_size_in_dwords << 2,
- PVR_BO_ALLOC_FLAG_CPU_MAPPED,
- &pvr_bo);
+ result =
+ pvr_cmd_buffer_alloc_mem(cmd_buffer,
+ cmd_buffer->device->heaps.pds_heap,
+ PVR_DW_TO_BYTES(pds_info->data_size_in_dwords),
+ PVR_BO_ALLOC_FLAG_CPU_MAPPED,
+ &pvr_bo);
if (result != VK_SUCCESS)
return result;
if (!pds_info->data_size_in_dwords)
return VK_SUCCESS;
- result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
- cmd_buffer->device->heaps.pds_heap,
- pds_info->data_size_in_dwords << 2,
- PVR_BO_ALLOC_FLAG_CPU_MAPPED,
- &pvr_bo);
+ result =
+ pvr_cmd_buffer_alloc_mem(cmd_buffer,
+ cmd_buffer->device->heaps.pds_heap,
+ PVR_DW_TO_BYTES(pds_info->data_size_in_dwords),
+ PVR_BO_ALLOC_FLAG_CPU_MAPPED,
+ &pvr_bo);
if (result != VK_SUCCESS)
return result;
assert(descriptor->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
assert(descriptor->buffer_desc_range ==
- const_buffer_entry->size_in_dwords * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(const_buffer_entry->size_in_dwords));
assert(descriptor->buffer_whole_range ==
- const_buffer_entry->size_in_dwords * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(const_buffer_entry->size_in_dwords));
buffer_addr =
PVR_DEV_ADDR_OFFSET(descriptor->buffer_dev_addr,
const uint32_t desc_set_num = desc_set_entry->descriptor_set;
const struct pvr_descriptor_set *descriptor_set;
pvr_dev_addr_t desc_set_addr;
+ uint64_t desc_portion_offset;
assert(desc_set_num < PVR_MAX_DESCRIPTOR_SETS);
desc_set_addr = descriptor_set->pvr_bo->vma->dev_addr;
if (desc_set_entry->primary) {
- desc_set_addr = PVR_DEV_ADDR_OFFSET(
- desc_set_addr,
+ desc_portion_offset =
descriptor_set->layout->memory_layout_in_dwords_per_stage[stage]
- .primary_offset
- << 2U);
+ .primary_offset;
} else {
- desc_set_addr = PVR_DEV_ADDR_OFFSET(
- desc_set_addr,
+ desc_portion_offset =
descriptor_set->layout->memory_layout_in_dwords_per_stage[stage]
- .secondary_offset
- << 2U);
+ .secondary_offset;
}
+ desc_portion_offset = PVR_DW_TO_BYTES(desc_portion_offset);
+
+ desc_set_addr =
+ PVR_DEV_ADDR_OFFSET(desc_set_addr, desc_portion_offset);
desc_set_addr = PVR_DEV_ADDR_OFFSET(
desc_set_addr,
- (uint64_t)desc_set_entry->offset_in_dwords << 2U);
+ PVR_DW_TO_BYTES((uint64_t)desc_set_entry->offset_in_dwords));
PVR_WRITE(qword_buffer,
desc_set_addr.addr,
{
const struct pvr_descriptor_set_layout *layout = desc_set->layout;
const uint64_t normal_desc_set_size =
- layout->total_size_in_dwords * sizeof(uint32_t);
+ PVR_DW_TO_BYTES(layout->total_size_in_dwords);
const uint64_t dynamic_descs_size =
- layout->total_dynamic_size_in_dwords * sizeof(uint32_t);
+ PVR_DW_TO_BYTES(layout->total_dynamic_size_in_dwords);
struct pvr_descriptor_size_info dynamic_uniform_buffer_size_info;
struct pvr_descriptor_size_info dynamic_storage_buffer_size_info;
struct pvr_device *device = cmd_buffer->device;
memcpy(mem_ptr + primary_offset + size_info->primary * desc_idx,
&addr.addr,
- size_info->primary * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(size_info->primary));
memcpy(mem_ptr + secondary_offset + size_info->secondary * desc_idx,
&range,
- size_info->secondary * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(size_info->secondary));
}
}
}
result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
cmd_buffer->device->heaps.pds_heap,
- pds_info->data_size_in_dwords << 2,
+ PVR_DW_TO_BYTES(pds_info->data_size_in_dwords),
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pvr_bo);
if (result != VK_SUCCESS)
info.pds_data_offset = state->pds_compute_descriptor_data_offset;
info.pds_data_size =
- DIV_ROUND_UP(pds_data_size_in_dwords << 2U,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(pds_data_size_in_dwords),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE));
/* Check that we have upload the code section. */
info.pds_data_offset = program->data_offset;
info.pds_data_size =
- DIV_ROUND_UP(program->data_size << 2U,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(program->data_size),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE));
info.pds_code_offset = program->code_offset;
}
DIV_ROUND_UP(const_shared_regs,
PVRX(CDMCTRL_KERNEL0_USC_COMMON_SIZE_UNIT_SIZE)),
.pds_data_size =
- DIV_ROUND_UP(pipeline->pds_shared_update_data_size_dw << 2U,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(pipeline->pds_shared_update_data_size_dw),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE)),
.usc_target = PVRX(CDMCTRL_USC_TARGET_ALL),
.pds_data_offset = pipeline->pds_shared_update_data_offset,
PVRX(CDMCTRL_KERNEL0_PDS_TEMP_SIZE_UNIT_SIZE)),
.pds_data_size =
- DIV_ROUND_UP(pipeline->pds_data_size_dw << 2U,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(pipeline->pds_data_size_dw),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE)),
.pds_data_offset = pipeline->pds_data_offset,
.pds_code_offset = pipeline->pds_code_offset,
PVRX(CDMCTRL_KERNEL0_PDS_TEMP_SIZE_UNIT_SIZE)),
.pds_data_size =
- DIV_ROUND_UP(program_info->data_size_in_dwords << 2U,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(program_info->data_size_in_dwords),
PVRX(CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE)),
.pds_data_offset = pipeline->primary_program.data_offset,
.pds_code_offset = pipeline->primary_program.code_offset,
PVRX(VDMCTRL_PDS_STATE0_USC_COMMON_SIZE_UNIT_SIZE));
state0.pds_data_size = DIV_ROUND_UP(
- vertex_descriptor_state->pds_info.data_size_in_dwords << 2,
+ PVR_DW_TO_BYTES(vertex_descriptor_state->pds_info.data_size_in_dwords),
PVRX(VDMCTRL_PDS_STATE0_PDS_DATA_SIZE_UNIT_SIZE));
}
result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
cmd_buffer->device->heaps.general_heap,
- ppp_state_words_count * sizeof(uint32_t),
+ PVR_DW_TO_BYTES(ppp_state_words_count),
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pvr_bo);
if (result != VK_SUCCESS)
memcpy(pvr_bo->bo->map,
ppp_state_words,
- ppp_state_words_count * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(ppp_state_words_count));
/* Write the VDM state update into the VDM control stream. */
pvr_csb_emit (control_stream, VDMCTRL_PPP_STATE0, state0) {
state5.vs_pds_temp_size =
DIV_ROUND_UP(state->pds_shader.info->temps_required << 2,
PVRX(VDMCTRL_VDM_STATE5_VS_PDS_TEMP_SIZE_UNIT_SIZE));
- state5.vs_pds_data_size =
- DIV_ROUND_UP(state->pds_shader.info->data_size_in_dwords << 2,
- PVRX(VDMCTRL_VDM_STATE5_VS_PDS_DATA_SIZE_UNIT_SIZE));
+ state5.vs_pds_data_size = DIV_ROUND_UP(
+ PVR_DW_TO_BYTES(state->pds_shader.info->data_size_in_dwords),
+ PVRX(VDMCTRL_VDM_STATE5_VS_PDS_DATA_SIZE_UNIT_SIZE));
}
}
}
dev_info);
}
- pds_size = (pds_prog.program.data_size_aligned +
- pds_prog.program.code_size_aligned)
- << 2;
+ pds_size = PVR_DW_TO_BYTES(pds_prog.program.data_size_aligned +
+ pds_prog.program.code_size_aligned);
result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
cmd_buffer->device->heaps.pds_heap,
pds_base = pds_bo->bo->map;
memcpy(pds_base,
pds_prog.program.code,
- pds_prog.program.code_size_aligned << 2);
+ PVR_DW_TO_BYTES(pds_prog.program.code_size_aligned));
if (state->draw_state.draw_indexed) {
pvr_pds_generate_draw_elements_indirect(
state0.usc_target = PVRX(VDMCTRL_USC_TARGET_ANY);
state0.pds_temp_size =
- DIV_ROUND_UP(pds_prog.program.temp_size_aligned << 2,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(pds_prog.program.temp_size_aligned),
PVRX(VDMCTRL_PDS_STATE0_PDS_TEMP_SIZE_UNIT_SIZE));
state0.pds_data_size =
- DIV_ROUND_UP(pds_prog.program.data_size_aligned << 2,
+ DIV_ROUND_UP(PVR_DW_TO_BYTES(pds_prog.program.data_size_aligned),
PVRX(VDMCTRL_PDS_STATE0_PDS_DATA_SIZE_UNIT_SIZE));
}
pvr_csb_emit (csb, VDMCTRL_PDS_STATE1, state1) {
const uint32_t data_offset =
- pds_bo->vma->dev_addr.addr + (pds_prog.program.code_size << 2) -
+ pds_bo->vma->dev_addr.addr +
+ PVR_DW_TO_BYTES(pds_prog.program.code_size) -
cmd_buffer->device->heaps.pds_heap->base_addr.addr;
state1.pds_data_addr = PVR_DEV_ADDR(data_offset);
/* Emit VDM state. */
static_assert(sizeof(device->static_clear_state.large_clear_vdm_words) >=
- PVR_CLEAR_VDM_STATE_DWORD_COUNT * sizeof(uint32_t),
+ PVR_DW_TO_BYTES(PVR_CLEAR_VDM_STATE_DWORD_COUNT),
"Large clear VDM control stream word length mismatch");
static_assert(sizeof(device->static_clear_state.vdm_words) ==
- PVR_CLEAR_VDM_STATE_DWORD_COUNT * sizeof(uint32_t),
+ PVR_DW_TO_BYTES(PVR_CLEAR_VDM_STATE_DWORD_COUNT),
"Clear VDM control stream word length mismatch");
pvr_emit_clear_words(cmd_buffer, sub_cmd);
ROGUE_NUM_TEXSTATE_IMAGE_WORDS * sizeof(uint64_t));
CHECK_STRUCT_FIELD_SIZE(pvr_combined_image_sampler_descriptor,
image,
- PVR_IMAGE_DESCRIPTOR_SIZE * sizeof(uint32_t));
+ PVR_DW_TO_BYTES(PVR_IMAGE_DESCRIPTOR_SIZE));
#if 0
/* TODO: Don't really want to include pvr_csb.h in here since this header is
* shared with the compiler. Figure out a better place for these.
#include "pvr_debug.h"
#include "pvr_device_info.h"
#include "pvr_private.h"
+#include "pvr_types.h"
#include "util/list.h"
#include "util/u_dynarray.h"
#include "vk_log.h"
*/
void *pvr_csb_alloc_dwords(struct pvr_csb *csb, uint32_t num_dwords)
{
- const uint32_t required_space = num_dwords * 4;
+ const uint32_t required_space = PVR_DW_TO_BYTES(num_dwords);
void *p;
if (csb->status != VK_SUCCESS)
* This can be used by the caller to modify the command or
* state information before it's packed.
*/
-#define pvr_csb_pack(_dst, cmd, name) \
- for (struct PVRX(cmd) name = { pvr_cmd_header(cmd) }, \
- *_loop_terminate = &name; \
- __builtin_expect(_loop_terminate != NULL, 1); \
- ({ \
- STATIC_ASSERT(sizeof(*(_dst)) == pvr_cmd_length(cmd) * 4); \
- pvr_cmd_pack(cmd)((_dst), &name); \
- _loop_terminate = NULL; \
+#define pvr_csb_pack(_dst, cmd, name) \
+ for (struct PVRX(cmd) name = { pvr_cmd_header(cmd) }, \
+ *_loop_terminate = &name; \
+ __builtin_expect(_loop_terminate != NULL, 1); \
+ ({ \
+ STATIC_ASSERT(sizeof(*(_dst)) == \
+ PVR_DW_TO_BYTES(pvr_cmd_length(cmd))); \
+ pvr_cmd_pack(cmd)((_dst), &name); \
+ _loop_terminate = NULL; \
}))
/**
* \param[in] _src Pointer to read the packed command/state from.
* \param[in] cmd Command/state type.
*/
-#define pvr_csb_unpack(_src, cmd) \
- ({ \
- struct PVRX(cmd) _name; \
- STATIC_ASSERT(sizeof(*(_src)) == pvr_cmd_length(cmd) * 4); \
- pvr_cmd_unpack(cmd)((_src), &_name); \
- _name; \
+#define pvr_csb_unpack(_src, cmd) \
+ ({ \
+ struct PVRX(cmd) _name; \
+ STATIC_ASSERT(sizeof(*(_src)) == PVR_DW_TO_BYTES(pvr_cmd_length(cmd))); \
+ pvr_cmd_unpack(cmd)((_src), &_name); \
+ _name; \
})
/**
* \param[in] cmd Command/state type.
* \param[in] val Pre-packed value to write.
*/
-#define pvr_csb_write_value(dst, cmd, val) \
- do { \
- static_assert(sizeof(*(dst)) == pvr_cmd_length(cmd) * sizeof(uint32_t), \
- "Size mismatch"); \
- static_assert(sizeof(*(dst)) == sizeof(val), "Size mismatch"); \
- *(dst) = (val); \
- (dst)++; \
+#define pvr_csb_write_value(dst, cmd, val) \
+ do { \
+ static_assert(sizeof(*(dst)) == PVR_DW_TO_BYTES(pvr_cmd_length(cmd)), \
+ "Size mismatch"); \
+ static_assert(sizeof(*(dst)) == sizeof(val), "Size mismatch"); \
+ *(dst) = (val); \
+ (dst)++; \
} while (0)
/**
* \param[in] cmd Command/state type.
* \param[in] val Command/state struct to pack and write.
*/
-#define pvr_csb_write_struct(dst, cmd, val) \
- do { \
- static_assert(sizeof(*(dst)) == pvr_cmd_length(cmd) * sizeof(uint32_t), \
- "Size mismatch"); \
- pvr_cmd_pack(cmd)((dst), (val)); \
- (dst)++; \
+#define pvr_csb_write_struct(dst, cmd, val) \
+ do { \
+ static_assert(sizeof(*(dst)) == PVR_DW_TO_BYTES(pvr_cmd_length(cmd)), \
+ "Size mismatch"); \
+ pvr_cmd_pack(cmd)((dst), (val)); \
+ (dst)++; \
} while (0)
/**@}*/
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset_in_dwords += 4;
- memcpy((uint8_t *)map + offset_in_dwords * sizeof(uint32_t),
+ memcpy((uint8_t *)map + PVR_DW_TO_BYTES(offset_in_dwords),
sampler->descriptor.words,
sizeof(sampler->descriptor.words));
}
j,
write_set->dstArrayElement + i);
- memcpy(mem_ptr + primary_offset, &addr, size_info.primary << 2);
- memcpy(mem_ptr + secondary_offset, &range, size_info.secondary << 2);
+ memcpy(mem_ptr + primary_offset,
+ &addr,
+ PVR_DW_TO_BYTES(size_info.primary));
+ memcpy(mem_ptr + secondary_offset,
+ &range,
+ PVR_DW_TO_BYTES(size_info.secondary));
}
}
}
memcpy(dst_mem_ptr + dst_primary_offset,
src_mem_ptr + src_primary_offset,
- size_info.primary * 4U * copy_set->descriptorCount);
+ PVR_DW_TO_BYTES(size_info.primary) * copy_set->descriptorCount);
memcpy(dst_mem_ptr + dst_secondary_offset,
src_mem_ptr + src_secondary_offset,
- size_info.secondary * 4U * copy_set->descriptorCount);
+ PVR_DW_TO_BYTES(size_info.secondary) * copy_set->descriptorCount);
}
}
*/
/* Code size is in bytes, data size in dwords. */
staging_buffer_size =
- program->data_size * sizeof(uint32_t) + program->code_size;
+ PVR_DW_TO_BYTES(program->data_size) + program->code_size;
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
pvr_pds_vertex_shader_sa(&program, NULL, PDS_GENERATE_SIZES, dev_info);
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
pvr_pds_vertex_shader_sa(&program, NULL, PDS_GENERATE_SIZES, dev_info);
staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_realloc(&device->vk.alloc,
staging_buffer,
pvr_pds_set_sizes_pixel_shader(&program);
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
struct pvr_pds_upload *const pds_upload_out)
{
/* All alignment and sizes below are in bytes. */
- const size_t data_size = data_size_dwords * sizeof(*data);
- const size_t code_size = code_size_dwords * sizeof(*code);
+ const size_t data_size = PVR_DW_TO_BYTES(data_size_dwords);
+ const size_t code_size = PVR_DW_TO_BYTES(code_size_dwords);
const uint64_t data_aligned_size = ALIGN_POT(data_size, data_alignment);
const uint64_t code_aligned_size = ALIGN_POT(code_size, code_alignment);
const uint32_t code_offset = ALIGN_POT(data_aligned_size, code_alignment);
#include "pvr_job_context.h"
#include "pvr_job_compute.h"
#include "pvr_private.h"
+#include "pvr_types.h"
#include "pvr_winsys.h"
#include "util/macros.h"
stream_ptr += pvr_cmd_length(CR_CDM_CONTEXT_STATE_BASE);
pvr_csb_pack (stream_ptr, CR_CDM_CONTEXT_PDS1, state) {
- /* Convert the data size from dwords to bytes. */
const uint32_t load_program_data_size =
- ctx_switch->sr[0].pds.load_program.data_size * 4U;
+ PVR_DW_TO_BYTES(ctx_switch->sr[0].pds.load_program.data_size);
state.pds_seq_dep = false;
state.usc_seq_dep = false;
PDS_GENERATE_CODE_SEGMENT,
dev_info);
- assert((uint32_t)(buffer_end - staging_buffer) * 4 <
+ assert((uint32_t)(buffer_end - staging_buffer) * sizeof(staging_buffer[0]) <
ROGUE_PDS_TASK_PROGRAM_SIZE);
return pvr_gpu_upload_pds(device,
dev_info);
}
- assert((uint32_t)(buffer_ptr - staging_buffer) * 4 <
+ assert((uint32_t)(buffer_ptr - staging_buffer) * sizeof(staging_buffer[0]) <
ROGUE_PDS_TASK_PROGRAM_SIZE);
STATIC_ASSERT(PVRX(CR_CDM_CONTEXT_PDS0_DATA_ADDR_ALIGNMENT) ==
{
pvr_csb_pack (state0_out, VDMCTRL_PDS_STATE0, state) {
/* Convert the data size from dwords to bytes. */
- const uint32_t pds_data_size = pds_program->data_size * 4;
+ const uint32_t pds_data_size = PVR_DW_TO_BYTES(pds_program->data_size);
state.dm_target = PVRX(VDMCTRL_DM_TARGET_VDM);
state.usc_target = usc_target;
{
pvr_csb_pack (stream_out1_out, TA_STATE_STREAM_OUT1, state) {
/* Convert the data size from dwords to bytes. */
- const uint32_t pds_data_size = pds_program->data_size * 4;
+ const uint32_t pds_data_size = PVR_DW_TO_BYTES(pds_program->data_size);
state.sync = true;
PDS_GENERATE_CODE_SEGMENT,
&device->pdevice->dev_info);
- assert((uint64_t)(buffer_end - staging_buffer) * 4U <
+ assert((uint64_t)(buffer_end - staging_buffer) * sizeof(staging_buffer[0]) <
ROGUE_PDS_TASK_PROGRAM_SIZE);
return pvr_gpu_upload_pds(device,
pvr_csb_pack (&static_state->cdm_ctx_store_pds1,
CR_CDM_CONTEXT_PDS1,
state) {
- /* Convert the data size from dwords to bytes. */
const uint32_t store_program_data_size =
- ctx_switch->sr[0].pds.store_program.data_size * 4U;
+ PVR_DW_TO_BYTES(ctx_switch->sr[0].pds.store_program.data_size);
state.pds_seq_dep = true;
state.usc_seq_dep = false;
state) {
/* Convert the data size from dwords to bytes. */
const uint32_t fence_terminate_program_data_size =
- ctx_switch->sr_fence_terminate_program.data_size * 4U;
+ PVR_DW_TO_BYTES(ctx_switch->sr_fence_terminate_program.data_size);
state.pds_seq_dep = true;
state.usc_seq_dep = false;
pvr_pds_set_sizes_pixel_event(&program, dev_info);
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
ALIGN_POT(program->data_size,
PVRX(TA_STATE_PDS_SIZEINFO1_PDS_TEXTURESTATESIZE_UNIT_SIZE));
- result = pvr_cmd_buffer_alloc_mem(transfer_cmd->cmd_buffer,
- ctx->device->heaps.pds_heap,
- state->tex_state_data_size << 2U,
- PVR_BO_ALLOC_FLAG_CPU_MAPPED,
- &pvr_bo);
+ result =
+ pvr_cmd_buffer_alloc_mem(transfer_cmd->cmd_buffer,
+ ctx->device->heaps.pds_heap,
+ PVR_DW_TO_BYTES(state->tex_state_data_size),
+ PVR_BO_ALLOC_FLAG_CPU_MAPPED,
+ &pvr_bo);
if (result != VK_SUCCESS)
return result;
result = pvr_cmd_buffer_alloc_mem(transfer_cmd->cmd_buffer,
device->heaps.general_heap,
- tex_state_dma_size_dw << 2U,
+ PVR_DW_TO_BYTES(tex_state_dma_size_dw),
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pvr_bo);
if (result != VK_SUCCESS)
pvr_pds_set_sizes_coeff_loading(&program);
- result =
- pvr_cmd_buffer_alloc_mem(transfer_cmd->cmd_buffer,
- ctx->device->heaps.pds_heap,
- (program.data_size + program.code_size) << 2U,
- PVR_BO_ALLOC_FLAG_CPU_MAPPED,
- &pvr_bo);
+ result = pvr_cmd_buffer_alloc_mem(
+ transfer_cmd->cmd_buffer,
+ ctx->device->heaps.pds_heap,
+ PVR_DW_TO_BYTES(program.data_size + program.code_size),
+ PVR_BO_ALLOC_FLAG_CPU_MAPPED,
+ &pvr_bo);
if (result != VK_SUCCESS)
return result;
src->surface.mem_layout == PVR_MEMLAYOUT_3DTWIDDLED ? 4U : 2U;
}
- tsp_data_size = num_isp_vertices * PVR_TRANSFER_NUM_LAYERS * 4U *
- num_tsp_vertices_per_isp_vertex;
+ tsp_data_size = PVR_DW_TO_BYTES(num_isp_vertices * PVR_TRANSFER_NUM_LAYERS *
+ num_tsp_vertices_per_isp_vertex);
if (PVR_HAS_FEATURE(dev_info, simple_internal_parameter_format)) {
/* An XYZ vertex is 16/16/32 bits => 8 bytes. */
pds_state_size_dw = 7U;
}
- stream_size = tsp_data_size + (idx_data_size_dw + tsp_comp_format_dw +
- isp_vertex_data_size_dw + isp_state_size_dw +
- pds_state_size_dw) *
- 4U;
+ stream_size =
+ tsp_data_size + PVR_DW_TO_BYTES(idx_data_size_dw + tsp_comp_format_dw +
+ isp_vertex_data_size_dw +
+ isp_state_size_dw + pds_state_size_dw);
return stream_size;
}
src->surface.mem_layout == PVR_MEMLAYOUT_3DTWIDDLED ? 4U : 2U;
}
- tsp_data_size_in_bytes = num_isp_vertices * PVR_TRANSFER_NUM_LAYERS * 4U *
- num_tsp_vertices_per_isp_vert;
+ tsp_data_size_in_bytes =
+ PVR_DW_TO_BYTES(num_isp_vertices * PVR_TRANSFER_NUM_LAYERS *
+ num_tsp_vertices_per_isp_vert);
if (PVR_HAS_FEATURE(dev_info, simple_internal_parameter_format)) {
tsp_comp_format_in_dw = 0U;
pvr_isp_prim_block_pds_state(dev_info, ctx, state, cs_ptr_out);
/* Point the CS_PRIM_BASE here. */
- *cs_start_offset = (*cs_ptr_out - cs_ptr_start) * sizeof(uint32_t);
+ *cs_start_offset = (*cs_ptr_out - cs_ptr_start) * sizeof(cs_ptr_start[0]);
/* This includes:
* ISP state words.
return result;
}
- assert((*cs_ptr_out - cs_ptr_start) * sizeof(uint32_t) ==
+ assert((*cs_ptr_out - cs_ptr_start) * sizeof(cs_ptr_start[0]) ==
stream_size_in_bytes);
return VK_SUCCESS;
static inline uint32_t
pvr_transfer_prim_blocks_per_alloc(const struct pvr_device_info *dev_info)
{
- uint32_t ret = PVRX(IPF_CONTROL_STREAM_SIZE_DWORDS) * sizeof(uint32_t);
+ uint32_t ret = PVR_DW_TO_BYTES(PVRX(IPF_CONTROL_STREAM_SIZE_DWORDS));
if (PVR_HAS_FEATURE(dev_info, simple_internal_parameter_format))
return ret / sizeof(uint64_t) / 2U;
num_region_arrays++;
next_region_array_vaddr.addr +=
num_region_arrays *
- (PVRX(IPF_CONTROL_STREAM_SIZE_DWORDS) * 4);
+ PVR_DW_TO_BYTES(PVRX(IPF_CONTROL_STREAM_SIZE_DWORDS));
if (PVR_HAS_FEATURE(dev_info,
simple_internal_parameter_format_v2)) {
pvr_isp_ctrl_stream_sipf_write_aligned(
(uint8_t *)cs_ptr,
link_addr,
- pvr_cmd_length(IPF_CONTROL_STREAM_LINK_SIPF2) * 4);
+ PVR_DW_TO_BYTES(
+ pvr_cmd_length(IPF_CONTROL_STREAM_LINK_SIPF2)));
} else {
pvr_csb_pack (cs_ptr, IPF_CONTROL_STREAM, control_stream) {
control_stream.cs_type = PVRX(IPF_CS_TYPE_LINK);
#include "pvr_hw_pass.h"
#include "pvr_pds.h"
#include "pvr_private.h"
+#include "pvr_types.h"
#include "pvr_usc_fragment_shader.h"
#include "util/macros.h"
#include "rogue/rogue.h"
pvr_pds_set_sizes_pixel_shader_uniform_texture_code(&program);
- staging_buffer_size = program.code_size * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size);
staging_buffer = vk_alloc2(&device->vk.alloc,
allocator,
return VK_SUCCESS;
}
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc2(&device->vk.alloc,
allocator,
pvr_pds_kick_usc(&program, NULL, 0, false, PDS_GENERATE_SIZES);
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc2(&device->vk.alloc,
allocator,
&device->pdevice->dev_info);
code_size_in_dwords = info->code_size_in_dwords;
- staging_buffer_size = info->code_size_in_dwords * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(info->code_size_in_dwords);
staging_buffer = vk_alloc2(&device->vk.alloc,
allocator,
pvr_pds_generate_descriptor_upload_program(&program, NULL, pds_info);
code_size_in_dwords = pds_info->code_size_in_dwords;
- staging_buffer_size =
- pds_info->code_size_in_dwords * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(pds_info->code_size_in_dwords);
if (!staging_buffer_size) {
vk_free2(&device->vk.alloc, allocator, entries_buffer);
/* FIXME: According to pvr_device_init_compute_pds_program() the code size
* is in bytes. Investigate this.
*/
- staging_buffer_size =
- (program.code_size + program.data_size) * sizeof(*staging_buffer);
+ staging_buffer_size = PVR_DW_TO_BYTES(program.code_size + program.data_size);
staging_buffer = vk_alloc2(&device->vk.alloc,
allocator,
/* FIXME: According to pvr_device_init_compute_pds_program() the code size
* is in bytes. Investigate this.
*/
- buffer_size = MAX2(program.code_size, program.data_size) * sizeof(*buffer);
+ buffer_size = PVR_DW_TO_BYTES(MAX2(program.code_size, program.data_size));
buffer = vk_alloc2(&device->vk.alloc,
allocator,
#include "pvr_shader_factory.h"
#include "pvr_static_shaders.h"
#include "pvr_tex_state.h"
+#include "pvr_types.h"
#include "vk_alloc.h"
#include "vk_command_pool.h"
#include "vk_util.h"
staging_buffer_size = info->code_size_in_dwords;
staging_buffer = vk_alloc(&device->vk.alloc,
- staging_buffer_size * sizeof(*staging_buffer),
+ PVR_DW_TO_BYTES(staging_buffer_size),
8,
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (!staging_buffer) {
result = pvr_cmd_buffer_alloc_mem(cmd_buffer,
cmd_buffer->device->heaps.pds_heap,
- info->data_size_in_dwords << 2,
+ PVR_DW_TO_BYTES(info->data_size_in_dwords),
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pvr_bo);
if (result != VK_SUCCESS)
* not needed. If it's needed we should probably be using LITERAL entries for
* this instead.
*/
- memset(dword_buffer, 0xFE, info->data_size_in_dwords << 2);
+ memset(dword_buffer, 0xFE, PVR_DW_TO_BYTES(info->data_size_in_dwords));
pipeline->pds_shared_update_data_size_dw = info->data_size_in_dwords;
buffer_size = ALIGN_POT((uint64_t)framebuffer_width,
PVRX(CR_PBE_WORD0_MRT0_LINESTRIDE_ALIGNMENT));
- buffer_size *= (uint64_t)framebuffer_height * dwords_per_pixel * 4;
+ buffer_size *=
+ (uint64_t)framebuffer_height * PVR_DW_TO_BYTES(dwords_per_pixel);
return buffer_size;
}
pds_texture_aligned_offsets[i] = pds_allocation_size;
/* FIXME: Figure out the define for alignment of 16. */
- pds_allocation_size += ALIGN_POT(pds_texture_program.code_size * 4, 16);
+ pds_allocation_size +=
+ ALIGN_POT(PVR_DW_TO_BYTES(pds_texture_program.code_size), 16);
pvr_pds_set_sizes_pixel_shader(&pds_kick_program);
pds_kick_aligned_offsets[i] = pds_allocation_size;
/* FIXME: Figure out the define for alignment of 16. */
- pds_allocation_size += ALIGN_POT(
- (pds_kick_program.code_size + pds_kick_program.data_size) * 4,
- 16);
+ pds_allocation_size +=
+ ALIGN_POT(PVR_DW_TO_BYTES(pds_kick_program.code_size +
+ pds_kick_program.data_size),
+ 16);
}
/* FIXME: Figure out the define for alignment of 16. */
pbe_reg_words_out);
return (uint64_t)stride * framebuffer_size->height * sample_count *
- dword_count * sizeof(uint32_t);
+ PVR_DW_TO_BYTES(dword_count);
}
static inline void pvr_set_pbe_all_valid_mask(struct usc_mrt_desc *desc)
mrt_resources[render_target_used] = (struct usc_mrt_resource){
.mrt_desc = {
- .intermediate_size = max_pbe_write_size_dw * sizeof(uint32_t),
+ .intermediate_size = PVR_DW_TO_BYTES(max_pbe_write_size_dw),
},
.type = source_type,
- .intermediate_size = max_pbe_write_size_dw * sizeof(uint32_t),
+ .intermediate_size = PVR_DW_TO_BYTES(max_pbe_write_size_dw),
};
if (source_type == USC_MRT_RESOURCE_TYPE_MEMORY)
mrt_resources[render_target_used] = (struct usc_mrt_resource){
.mrt_desc = {
- .intermediate_size = max_pbe_write_size_dw * sizeof(uint32_t),
+ .intermediate_size = PVR_DW_TO_BYTES(max_pbe_write_size_dw),
},
.type = source_type,
- .intermediate_size = max_pbe_write_size_dw * sizeof(uint32_t),
+ .intermediate_size = PVR_DW_TO_BYTES(max_pbe_write_size_dw),
};
if (source_type == USC_MRT_RESOURCE_TYPE_OUTPUT_REG) {
staging_buffer =
vk_alloc(&device->vk.alloc,
- device->pixel_event_data_size_in_dwords * sizeof(uint32_t),
+ PVR_DW_TO_BYTES(device->pixel_event_data_size_in_dwords),
8,
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (!staging_buffer)
if (result != VK_SUCCESS)
return result;
- *mem_used_out = fb_area * dword_count * sizeof(uint32_t) * sample_count;
+ *mem_used_out = fb_area * PVR_DW_TO_BYTES(dword_count) * sample_count;
return VK_SUCCESS;
}
assert(texture_program_data_size_in_dwords == texture_program.data_size);
#endif
- staging_buffer_size = texture_program_data_size_in_dwords * sizeof(uint32_t);
+ staging_buffer_size = PVR_DW_TO_BYTES(texture_program_data_size_in_dwords);
staging_buffer = vk_alloc(&device->vk.alloc,
staging_buffer_size,
pvr_pds_kick_usc(&kick_usc_pds_prog, NULL, 0U, false, PDS_GENERATE_SIZES);
- result = pvr_bo_alloc(
- device,
- device->heaps.pds_heap,
- (kick_usc_pds_prog.data_size + kick_usc_pds_prog.code_size) * 4,
- 16,
- PVR_BO_ALLOC_FLAG_CPU_MAPPED,
- &entry_data->kick_usc_pds_upload);
+ result = pvr_bo_alloc(device,
+ device->heaps.pds_heap,
+ PVR_DW_TO_BYTES(kick_usc_pds_prog.data_size +
+ kick_usc_pds_prog.code_size),
+ 16,
+ PVR_BO_ALLOC_FLAG_CPU_MAPPED,
+ &entry_data->kick_usc_pds_upload);
if (result != VK_SUCCESS)
goto err_free_usc_upload;