mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
panvk: Clang-format
We're going to enforce clang-format in CI, so get with the program! This doesn't change a *ton* all considered, because panvk was already aiming for the style we have in the panfrost clang-format file. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22372>
This commit is contained in:
parent
4ccf174009
commit
c7bf3b69eb
33 changed files with 2208 additions and 2376 deletions
|
|
@ -34,10 +34,8 @@
|
|||
#include "vk_format.h"
|
||||
|
||||
void
|
||||
panvk_CmdBindVertexBuffers(VkCommandBuffer commandBuffer,
|
||||
uint32_t firstBinding,
|
||||
uint32_t bindingCount,
|
||||
const VkBuffer *pBuffers,
|
||||
panvk_CmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
|
||||
uint32_t bindingCount, const VkBuffer *pBuffers,
|
||||
const VkDeviceSize *pOffsets)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -55,15 +53,14 @@ panvk_CmdBindVertexBuffers(VkCommandBuffer commandBuffer,
|
|||
panvk_buffer_range(buffer, pOffsets[i], VK_WHOLE_SIZE);
|
||||
}
|
||||
|
||||
cmdbuf->state.vb.count = MAX2(cmdbuf->state.vb.count, firstBinding + bindingCount);
|
||||
cmdbuf->state.vb.count =
|
||||
MAX2(cmdbuf->state.vb.count, firstBinding + bindingCount);
|
||||
desc_state->vs_attrib_bufs = desc_state->vs_attribs = 0;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdBindIndexBuffer(VkCommandBuffer commandBuffer,
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset,
|
||||
VkIndexType indexType)
|
||||
panvk_CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
|
||||
VkDeviceSize offset, VkIndexType indexType)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
VK_FROM_HANDLE(panvk_buffer, buf, buffer);
|
||||
|
|
@ -99,7 +96,7 @@ panvk_set_dyn_ssbo_pointers(struct panvk_descriptor_state *desc_state,
|
|||
const struct panvk_buffer_desc *ssbo =
|
||||
&desc_state->dyn.ssbos[dyn_ssbo_offset + i];
|
||||
|
||||
sysvals->dyn_ssbos[dyn_ssbo_offset + i] = (struct panvk_ssbo_addr) {
|
||||
sysvals->dyn_ssbos[dyn_ssbo_offset + i] = (struct panvk_ssbo_addr){
|
||||
.base_addr = panvk_buffer_gpu_ptr(ssbo->buffer, ssbo->offset),
|
||||
.size = panvk_buffer_range(ssbo->buffer, ssbo->offset, ssbo->size),
|
||||
};
|
||||
|
|
@ -111,8 +108,7 @@ panvk_set_dyn_ssbo_pointers(struct panvk_descriptor_state *desc_state,
|
|||
void
|
||||
panvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
||||
VkPipelineBindPoint pipelineBindPoint,
|
||||
VkPipelineLayout layout,
|
||||
uint32_t firstSet,
|
||||
VkPipelineLayout layout, uint32_t firstSet,
|
||||
uint32_t descriptorSetCount,
|
||||
const VkDescriptorSet *pDescriptorSets,
|
||||
uint32_t dynamicOffsetCount,
|
||||
|
|
@ -139,12 +135,16 @@ panvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
|||
for (unsigned e = 0; e < set->layout->bindings[b].array_size; e++) {
|
||||
struct panvk_buffer_desc *bdesc = NULL;
|
||||
|
||||
if (set->layout->bindings[b].type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
|
||||
if (set->layout->bindings[b].type ==
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
|
||||
bdesc = &descriptors_state->dyn.ubos[dyn_ubo_offset++];
|
||||
*bdesc = set->dyn_ubos[set->layout->bindings[b].dyn_ubo_idx + e];
|
||||
} else if (set->layout->bindings[b].type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
|
||||
*bdesc =
|
||||
set->dyn_ubos[set->layout->bindings[b].dyn_ubo_idx + e];
|
||||
} else if (set->layout->bindings[b].type ==
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
|
||||
bdesc = &descriptors_state->dyn.ssbos[dyn_ssbo_offset++];
|
||||
*bdesc = set->dyn_ssbos[set->layout->bindings[b].dyn_ssbo_idx + e];
|
||||
*bdesc =
|
||||
set->dyn_ssbos[set->layout->bindings[b].dyn_ssbo_idx + e];
|
||||
}
|
||||
|
||||
if (bdesc) {
|
||||
|
|
@ -156,8 +156,7 @@ panvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
|||
|
||||
if (set->layout->num_dyn_ssbos) {
|
||||
panvk_set_dyn_ssbo_pointers(descriptors_state,
|
||||
playout->sets[idx].dyn_ssbo_offset,
|
||||
set);
|
||||
playout->sets[idx].dyn_ssbo_offset, set);
|
||||
}
|
||||
|
||||
if (set->layout->num_dyn_ssbos)
|
||||
|
|
@ -174,7 +173,8 @@ panvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
|||
descriptors_state->samplers = 0;
|
||||
|
||||
if (set->layout->num_imgs) {
|
||||
descriptors_state->vs_attrib_bufs = descriptors_state->non_vs_attrib_bufs = 0;
|
||||
descriptors_state->vs_attrib_bufs =
|
||||
descriptors_state->non_vs_attrib_bufs = 0;
|
||||
descriptors_state->vs_attribs = descriptors_state->non_vs_attribs = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -183,12 +183,9 @@ panvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_CmdPushConstants(VkCommandBuffer commandBuffer,
|
||||
VkPipelineLayout layout,
|
||||
VkShaderStageFlags stageFlags,
|
||||
uint32_t offset,
|
||||
uint32_t size,
|
||||
const void *pValues)
|
||||
panvk_CmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
|
||||
VkShaderStageFlags stageFlags, uint32_t offset,
|
||||
uint32_t size, const void *pValues)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
||||
|
|
@ -225,11 +222,13 @@ panvk_CmdBindPipeline(VkCommandBuffer commandBuffer,
|
|||
if (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) {
|
||||
cmdbuf->state.varyings = pipeline->varyings;
|
||||
|
||||
if (!(pipeline->dynamic_state_mask & BITFIELD_BIT(VK_DYNAMIC_STATE_VIEWPORT))) {
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
BITFIELD_BIT(VK_DYNAMIC_STATE_VIEWPORT))) {
|
||||
cmdbuf->state.viewport = pipeline->viewport;
|
||||
cmdbuf->state.dirty |= PANVK_DYNAMIC_VIEWPORT;
|
||||
}
|
||||
if (!(pipeline->dynamic_state_mask & BITFIELD_BIT(VK_DYNAMIC_STATE_SCISSOR))) {
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
BITFIELD_BIT(VK_DYNAMIC_STATE_SCISSOR))) {
|
||||
cmdbuf->state.scissor = pipeline->scissor;
|
||||
cmdbuf->state.dirty |= PANVK_DYNAMIC_SCISSOR;
|
||||
}
|
||||
|
|
@ -242,10 +241,8 @@ panvk_CmdBindPipeline(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_CmdSetViewport(VkCommandBuffer commandBuffer,
|
||||
uint32_t firstViewport,
|
||||
uint32_t viewportCount,
|
||||
const VkViewport *pViewports)
|
||||
panvk_CmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
|
||||
uint32_t viewportCount, const VkViewport *pViewports)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
assert(viewportCount == 1);
|
||||
|
|
@ -257,10 +254,8 @@ panvk_CmdSetViewport(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_CmdSetScissor(VkCommandBuffer commandBuffer,
|
||||
uint32_t firstScissor,
|
||||
uint32_t scissorCount,
|
||||
const VkRect2D *pScissors)
|
||||
panvk_CmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
|
||||
uint32_t scissorCount, const VkRect2D *pScissors)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
assert(scissorCount == 1);
|
||||
|
|
@ -282,8 +277,7 @@ panvk_CmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
|
|||
|
||||
void
|
||||
panvk_CmdSetDepthBias(VkCommandBuffer commandBuffer,
|
||||
float depthBiasConstantFactor,
|
||||
float depthBiasClamp,
|
||||
float depthBiasConstantFactor, float depthBiasClamp,
|
||||
float depthBiasSlopeFactor)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -309,8 +303,7 @@ panvk_CmdSetBlendConstants(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_CmdSetDepthBounds(VkCommandBuffer commandBuffer,
|
||||
float minDepthBounds,
|
||||
panvk_CmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds,
|
||||
float maxDepthBounds)
|
||||
{
|
||||
panvk_stub();
|
||||
|
|
@ -335,8 +328,7 @@ panvk_CmdSetStencilCompareMask(VkCommandBuffer commandBuffer,
|
|||
|
||||
void
|
||||
panvk_CmdSetStencilWriteMask(VkCommandBuffer commandBuffer,
|
||||
VkStencilFaceFlags faceMask,
|
||||
uint32_t writeMask)
|
||||
VkStencilFaceFlags faceMask, uint32_t writeMask)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
||||
|
|
@ -352,8 +344,7 @@ panvk_CmdSetStencilWriteMask(VkCommandBuffer commandBuffer,
|
|||
|
||||
void
|
||||
panvk_CmdSetStencilReference(VkCommandBuffer commandBuffer,
|
||||
VkStencilFaceFlags faceMask,
|
||||
uint32_t reference)
|
||||
VkStencilFaceFlags faceMask, uint32_t reference)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
||||
|
|
@ -381,8 +372,8 @@ panvk_CreateCommandPool(VkDevice _device,
|
|||
if (pool == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
VkResult result = vk_command_pool_init(&device->vk, &pool->vk,
|
||||
pCreateInfo, pAllocator);
|
||||
VkResult result =
|
||||
vk_command_pool_init(&device->vk, &pool->vk, pCreateInfo, pAllocator);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free2(&device->vk.alloc, pAllocator, pool);
|
||||
return result;
|
||||
|
|
@ -400,27 +391,29 @@ panvk_cmd_prepare_clear_values(struct panvk_cmd_buffer *cmdbuf,
|
|||
const VkClearValue *in)
|
||||
{
|
||||
for (unsigned i = 0; i < cmdbuf->state.pass->attachment_count; i++) {
|
||||
const struct panvk_render_pass_attachment *attachment =
|
||||
&cmdbuf->state.pass->attachments[i];
|
||||
enum pipe_format fmt = attachment->format;
|
||||
const struct panvk_render_pass_attachment *attachment =
|
||||
&cmdbuf->state.pass->attachments[i];
|
||||
enum pipe_format fmt = attachment->format;
|
||||
|
||||
if (util_format_is_depth_or_stencil(fmt)) {
|
||||
if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR ||
|
||||
attachment->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
|
||||
cmdbuf->state.clear[i].depth = in[i].depthStencil.depth;
|
||||
cmdbuf->state.clear[i].stencil = in[i].depthStencil.stencil;
|
||||
} else {
|
||||
cmdbuf->state.clear[i].depth = 0;
|
||||
cmdbuf->state.clear[i].stencil = 0;
|
||||
}
|
||||
} else {
|
||||
if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
|
||||
union pipe_color_union *col = (union pipe_color_union *) &in[i].color;
|
||||
pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
|
||||
} else {
|
||||
memset(cmdbuf->state.clear[i].color, 0, sizeof(cmdbuf->state.clear[0].color));
|
||||
}
|
||||
}
|
||||
if (util_format_is_depth_or_stencil(fmt)) {
|
||||
if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR ||
|
||||
attachment->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
|
||||
cmdbuf->state.clear[i].depth = in[i].depthStencil.depth;
|
||||
cmdbuf->state.clear[i].stencil = in[i].depthStencil.stencil;
|
||||
} else {
|
||||
cmdbuf->state.clear[i].depth = 0;
|
||||
cmdbuf->state.clear[i].stencil = 0;
|
||||
}
|
||||
} else {
|
||||
if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
|
||||
union pipe_color_union *col =
|
||||
(union pipe_color_union *)&in[i].color;
|
||||
pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
|
||||
} else {
|
||||
memset(cmdbuf->state.clear[i].color, 0,
|
||||
sizeof(cmdbuf->state.clear[0].color));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -435,12 +428,12 @@ panvk_cmd_fb_info_set_subpass(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
fbinfo->nr_samples = 1;
|
||||
fbinfo->rt_count = subpass->color_count;
|
||||
memset(&fbinfo->bifrost.pre_post.dcds, 0, sizeof(fbinfo->bifrost.pre_post.dcds));
|
||||
memset(&fbinfo->bifrost.pre_post.dcds, 0,
|
||||
sizeof(fbinfo->bifrost.pre_post.dcds));
|
||||
|
||||
for (unsigned cb = 0; cb < subpass->color_count; cb++) {
|
||||
int idx = subpass->color_attachments[cb].idx;
|
||||
view = idx != VK_ATTACHMENT_UNUSED ?
|
||||
fb->attachments[idx].iview : NULL;
|
||||
view = idx != VK_ATTACHMENT_UNUSED ? fb->attachments[idx].iview : NULL;
|
||||
if (!view)
|
||||
continue;
|
||||
fbinfo->rts[cb].view = &view->pview;
|
||||
|
|
@ -464,13 +457,15 @@ panvk_cmd_fb_info_set_subpass(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
if (util_format_has_depth(fdesc)) {
|
||||
fbinfo->zs.clear.z = subpass->zs_attachment.clear;
|
||||
fbinfo->zs.clear_value.depth = clears[subpass->zs_attachment.idx].depth;
|
||||
fbinfo->zs.clear_value.depth =
|
||||
clears[subpass->zs_attachment.idx].depth;
|
||||
fbinfo->zs.view.zs = &view->pview;
|
||||
}
|
||||
|
||||
if (util_format_has_stencil(fdesc)) {
|
||||
fbinfo->zs.clear.s = subpass->zs_attachment.clear;
|
||||
fbinfo->zs.clear_value.stencil = clears[subpass->zs_attachment.idx].stencil;
|
||||
fbinfo->zs.clear_value.stencil =
|
||||
clears[subpass->zs_attachment.idx].stencil;
|
||||
if (!fbinfo->zs.view.zs)
|
||||
fbinfo->zs.view.s = &view->pview;
|
||||
}
|
||||
|
|
@ -485,7 +480,7 @@ panvk_cmd_fb_info_init(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
memset(cmdbuf->state.fb.crc_valid, 0, sizeof(cmdbuf->state.fb.crc_valid));
|
||||
|
||||
*fbinfo = (struct pan_fb_info) {
|
||||
*fbinfo = (struct pan_fb_info){
|
||||
.width = fb->width,
|
||||
.height = fb->height,
|
||||
.extent.maxx = fb->width - 1,
|
||||
|
|
@ -506,16 +501,16 @@ panvk_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
|
|||
cmdbuf->state.subpass = pass->subpasses;
|
||||
cmdbuf->state.framebuffer = fb;
|
||||
cmdbuf->state.render_area = pRenderPassBegin->renderArea;
|
||||
cmdbuf->state.batch = vk_zalloc(&cmdbuf->vk.pool->alloc,
|
||||
sizeof(*cmdbuf->state.batch), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
cmdbuf->state.batch =
|
||||
vk_zalloc(&cmdbuf->vk.pool->alloc, sizeof(*cmdbuf->state.batch), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
util_dynarray_init(&cmdbuf->state.batch->jobs, NULL);
|
||||
util_dynarray_init(&cmdbuf->state.batch->event_ops, NULL);
|
||||
assert(pRenderPassBegin->clearValueCount <= pass->attachment_count);
|
||||
cmdbuf->state.clear =
|
||||
vk_zalloc(&cmdbuf->vk.pool->alloc,
|
||||
sizeof(*cmdbuf->state.clear) * pass->attachment_count,
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
sizeof(*cmdbuf->state.clear) * pass->attachment_count, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
panvk_cmd_prepare_clear_values(cmdbuf, pRenderPassBegin->pClearValues);
|
||||
panvk_cmd_fb_info_init(cmdbuf);
|
||||
panvk_cmd_fb_info_set_subpass(cmdbuf);
|
||||
|
|
@ -538,7 +533,8 @@ panvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
if (cmdbuf->state.fb.info.zs.view.s ||
|
||||
(cmdbuf->state.fb.info.zs.view.zs &&
|
||||
util_format_is_depth_and_stencil(cmdbuf->state.fb.info.zs.view.zs->format))) {
|
||||
util_format_is_depth_and_stencil(
|
||||
cmdbuf->state.fb.info.zs.view.zs->format))) {
|
||||
cmdbuf->state.fb.info.zs.clear.s = false;
|
||||
cmdbuf->state.fb.info.zs.preload.s = true;
|
||||
}
|
||||
|
|
@ -548,48 +544,38 @@ struct panvk_batch *
|
|||
panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf)
|
||||
{
|
||||
assert(!cmdbuf->state.batch);
|
||||
cmdbuf->state.batch = vk_zalloc(&cmdbuf->vk.pool->alloc,
|
||||
sizeof(*cmdbuf->state.batch), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
cmdbuf->state.batch =
|
||||
vk_zalloc(&cmdbuf->vk.pool->alloc, sizeof(*cmdbuf->state.batch), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
assert(cmdbuf->state.batch);
|
||||
return cmdbuf->state.batch;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdDrawIndirect(VkCommandBuffer commandBuffer,
|
||||
VkBuffer _buffer,
|
||||
VkDeviceSize offset,
|
||||
uint32_t drawCount,
|
||||
uint32_t stride)
|
||||
panvk_CmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer _buffer,
|
||||
VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer,
|
||||
VkBuffer _buffer,
|
||||
VkDeviceSize offset,
|
||||
uint32_t drawCount,
|
||||
panvk_CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer _buffer,
|
||||
VkDeviceSize offset, uint32_t drawCount,
|
||||
uint32_t stride)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdDispatchBase(VkCommandBuffer commandBuffer,
|
||||
uint32_t base_x,
|
||||
uint32_t base_y,
|
||||
uint32_t base_z,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
panvk_CmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t base_x,
|
||||
uint32_t base_y, uint32_t base_z, uint32_t x, uint32_t y,
|
||||
uint32_t z)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdDispatchIndirect(VkCommandBuffer commandBuffer,
|
||||
VkBuffer _buffer,
|
||||
panvk_CmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer _buffer,
|
||||
VkDeviceSize offset)
|
||||
{
|
||||
panvk_stub();
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "util/macros.h"
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
#include "pan_cs.h"
|
||||
#include "pan_pool.h"
|
||||
|
|
@ -31,9 +31,9 @@
|
|||
#include "panvk_private.h"
|
||||
|
||||
/*
|
||||
* Upload the viewport scale. Defined as (px/2, py/2, pz) at the start of section
|
||||
* 24.5 ("Controlling the Viewport") of the Vulkan spec. At the end of the
|
||||
* section, the spec defines:
|
||||
* Upload the viewport scale. Defined as (px/2, py/2, pz) at the start of
|
||||
* section 24.5 ("Controlling the Viewport") of the Vulkan spec. At the end of
|
||||
* the section, the spec defines:
|
||||
*
|
||||
* px = width
|
||||
* py = height
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "panfrost-job.h"
|
||||
#include "pan_cs.h"
|
||||
#include "panfrost-job.h"
|
||||
|
||||
#include "vk_util.h"
|
||||
|
||||
|
|
@ -66,29 +66,30 @@ panvk_per_arch(translate_compare_func)(VkCompareOp comp)
|
|||
STATIC_ASSERT(VK_COMPARE_OP_LESS_OR_EQUAL == (VkCompareOp)MALI_FUNC_LEQUAL);
|
||||
STATIC_ASSERT(VK_COMPARE_OP_GREATER == (VkCompareOp)MALI_FUNC_GREATER);
|
||||
STATIC_ASSERT(VK_COMPARE_OP_NOT_EQUAL == (VkCompareOp)MALI_FUNC_NOT_EQUAL);
|
||||
STATIC_ASSERT(VK_COMPARE_OP_GREATER_OR_EQUAL == (VkCompareOp)MALI_FUNC_GEQUAL);
|
||||
STATIC_ASSERT(VK_COMPARE_OP_GREATER_OR_EQUAL ==
|
||||
(VkCompareOp)MALI_FUNC_GEQUAL);
|
||||
STATIC_ASSERT(VK_COMPARE_OP_ALWAYS == (VkCompareOp)MALI_FUNC_ALWAYS);
|
||||
|
||||
return (enum mali_func)comp;
|
||||
}
|
||||
|
||||
static inline enum mali_func
|
||||
panvk_per_arch(translate_sampler_compare_func)(const VkSamplerCreateInfo *pCreateInfo)
|
||||
panvk_per_arch(translate_sampler_compare_func)(
|
||||
const VkSamplerCreateInfo *pCreateInfo)
|
||||
{
|
||||
if (!pCreateInfo->compareEnable)
|
||||
return MALI_FUNC_NEVER;
|
||||
|
||||
enum mali_func f = panvk_per_arch(translate_compare_func)(pCreateInfo->compareOp);
|
||||
enum mali_func f =
|
||||
panvk_per_arch(translate_compare_func)(pCreateInfo->compareOp);
|
||||
return panfrost_flip_compare_func(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
panvk_sysval_upload_viewport_scale(const VkViewport *viewport,
|
||||
union panvk_sysval_vec4 *data);
|
||||
void panvk_sysval_upload_viewport_scale(const VkViewport *viewport,
|
||||
union panvk_sysval_vec4 *data);
|
||||
|
||||
void
|
||||
panvk_sysval_upload_viewport_offset(const VkViewport *viewport,
|
||||
union panvk_sysval_vec4 *data);
|
||||
void panvk_sysval_upload_viewport_offset(const VkViewport *viewport,
|
||||
union panvk_sysval_vec4 *data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,25 +39,23 @@
|
|||
#include "pan_bo.h"
|
||||
|
||||
/* FIXME: make sure those values are correct */
|
||||
#define PANVK_MAX_TEXTURES (1 << 16)
|
||||
#define PANVK_MAX_IMAGES (1 << 8)
|
||||
#define PANVK_MAX_SAMPLERS (1 << 16)
|
||||
#define PANVK_MAX_UBOS 255
|
||||
#define PANVK_MAX_TEXTURES (1 << 16)
|
||||
#define PANVK_MAX_IMAGES (1 << 8)
|
||||
#define PANVK_MAX_SAMPLERS (1 << 16)
|
||||
#define PANVK_MAX_UBOS 255
|
||||
|
||||
void
|
||||
panvk_GetDescriptorSetLayoutSupport(VkDevice _device,
|
||||
const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
||||
VkDescriptorSetLayoutSupport *pSupport)
|
||||
panvk_GetDescriptorSetLayoutSupport(
|
||||
VkDevice _device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
||||
VkDescriptorSetLayoutSupport *pSupport)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
||||
pSupport->supported = false;
|
||||
|
||||
VkDescriptorSetLayoutBinding *bindings;
|
||||
VkResult result =
|
||||
vk_create_sorted_bindings(pCreateInfo->pBindings,
|
||||
pCreateInfo->bindingCount,
|
||||
&bindings);
|
||||
VkResult result = vk_create_sorted_bindings(
|
||||
pCreateInfo->pBindings, pCreateInfo->bindingCount, &bindings);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_error(device, result);
|
||||
return;
|
||||
|
|
@ -130,8 +128,8 @@ panvk_CreatePipelineLayout(VkDevice _device,
|
|||
struct panvk_pipeline_layout *layout;
|
||||
struct mesa_sha1 ctx;
|
||||
|
||||
layout = vk_pipeline_layout_zalloc(&device->vk, sizeof(*layout),
|
||||
pCreateInfo);
|
||||
layout =
|
||||
vk_pipeline_layout_zalloc(&device->vk, sizeof(*layout), pCreateInfo);
|
||||
if (layout == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
@ -162,21 +160,26 @@ panvk_CreatePipelineLayout(VkDevice _device,
|
|||
|
||||
if (binding_layout->immutable_samplers) {
|
||||
for (unsigned s = 0; s < binding_layout->array_size; s++) {
|
||||
struct panvk_sampler *sampler = binding_layout->immutable_samplers[s];
|
||||
struct panvk_sampler *sampler =
|
||||
binding_layout->immutable_samplers[s];
|
||||
|
||||
_mesa_sha1_update(&ctx, &sampler->desc, sizeof(sampler->desc));
|
||||
}
|
||||
}
|
||||
_mesa_sha1_update(&ctx, &binding_layout->type, sizeof(binding_layout->type));
|
||||
_mesa_sha1_update(&ctx, &binding_layout->array_size, sizeof(binding_layout->array_size));
|
||||
_mesa_sha1_update(&ctx, &binding_layout->shader_stages, sizeof(binding_layout->shader_stages));
|
||||
_mesa_sha1_update(&ctx, &binding_layout->type,
|
||||
sizeof(binding_layout->type));
|
||||
_mesa_sha1_update(&ctx, &binding_layout->array_size,
|
||||
sizeof(binding_layout->array_size));
|
||||
_mesa_sha1_update(&ctx, &binding_layout->shader_stages,
|
||||
sizeof(binding_layout->shader_stages));
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned range = 0; range < pCreateInfo->pushConstantRangeCount; range++) {
|
||||
for (unsigned range = 0; range < pCreateInfo->pushConstantRangeCount;
|
||||
range++) {
|
||||
layout->push_constants.size =
|
||||
MAX2(pCreateInfo->pPushConstantRanges[range].offset +
|
||||
pCreateInfo->pPushConstantRanges[range].size,
|
||||
pCreateInfo->pPushConstantRanges[range].size,
|
||||
layout->push_constants.size);
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +225,7 @@ panvk_CreateDescriptorPool(VkDevice _device,
|
|||
for (unsigned i = 0; i < pCreateInfo->poolSizeCount; ++i) {
|
||||
unsigned desc_count = pCreateInfo->pPoolSizes[i].descriptorCount;
|
||||
|
||||
switch(pCreateInfo->pPoolSizes[i].type) {
|
||||
switch (pCreateInfo->pPoolSizes[i].type) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
pool->max.samplers += desc_count;
|
||||
break;
|
||||
|
|
@ -266,8 +269,7 @@ panvk_CreateDescriptorPool(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyDescriptorPool(VkDevice _device,
|
||||
VkDescriptorPool _pool,
|
||||
panvk_DestroyDescriptorPool(VkDevice _device, VkDescriptorPool _pool,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -278,8 +280,7 @@ panvk_DestroyDescriptorPool(VkDevice _device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_ResetDescriptorPool(VkDevice _device,
|
||||
VkDescriptorPool _pool,
|
||||
panvk_ResetDescriptorPool(VkDevice _device, VkDescriptorPool _pool,
|
||||
VkDescriptorPoolResetFlags flags)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_descriptor_pool, pool, _pool);
|
||||
|
|
@ -305,10 +306,8 @@ panvk_descriptor_set_destroy(struct panvk_device *device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_FreeDescriptorSets(VkDevice _device,
|
||||
VkDescriptorPool descriptorPool,
|
||||
uint32_t count,
|
||||
const VkDescriptorSet *pDescriptorSets)
|
||||
panvk_FreeDescriptorSets(VkDevice _device, VkDescriptorPool descriptorPool,
|
||||
uint32_t count, const VkDescriptorSet *pDescriptorSets)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_descriptor_pool, pool, descriptorPool);
|
||||
|
|
@ -323,10 +322,10 @@ panvk_FreeDescriptorSets(VkDevice _device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_CreateSamplerYcbcrConversion(VkDevice device,
|
||||
const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkSamplerYcbcrConversion *pYcbcrConversion)
|
||||
panvk_CreateSamplerYcbcrConversion(
|
||||
VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkSamplerYcbcrConversion *pYcbcrConversion)
|
||||
{
|
||||
panvk_stub();
|
||||
return VK_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -31,37 +31,36 @@
|
|||
#include "pan_bo.h"
|
||||
#include "pan_encoder.h"
|
||||
#include "pan_util.h"
|
||||
#include "vk_common_entrypoints.h"
|
||||
#include "vk_cmd_enqueue_entrypoints.h"
|
||||
#include "vk_common_entrypoints.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <libsync.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "drm-uapi/panfrost_drm.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/disk_cache.h"
|
||||
#include "util/strtod.h"
|
||||
#include "vk_format.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "vk_drm_syncobj.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#include <wayland-client.h>
|
||||
#include "wayland-drm-client-protocol.h"
|
||||
#include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#include "panvk_cs.h"
|
||||
|
||||
VkResult
|
||||
_panvk_device_set_lost(struct panvk_device *device,
|
||||
const char *file, int line,
|
||||
_panvk_device_set_lost(struct panvk_device *device, const char *file, int line,
|
||||
const char *msg, ...)
|
||||
{
|
||||
/* Set the flag indicating that waits should return in finite time even
|
||||
|
|
@ -94,8 +93,8 @@ panvk_device_get_cache_uuid(uint16_t family, void *uuid)
|
|||
|
||||
memset(uuid, 0, VK_UUID_SIZE);
|
||||
memcpy(uuid, &mesa_timestamp, 4);
|
||||
memcpy((char *) uuid + 4, &f, 2);
|
||||
snprintf((char *) uuid + 6, VK_UUID_SIZE - 10, "pan");
|
||||
memcpy((char *)uuid + 4, &f, 2);
|
||||
snprintf((char *)uuid + 6, VK_UUID_SIZE - 10, "pan");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -113,15 +112,10 @@ panvk_get_device_uuid(void *uuid)
|
|||
}
|
||||
|
||||
static const struct debug_control panvk_debug_options[] = {
|
||||
{ "startup", PANVK_DEBUG_STARTUP },
|
||||
{ "nir", PANVK_DEBUG_NIR },
|
||||
{ "trace", PANVK_DEBUG_TRACE },
|
||||
{ "sync", PANVK_DEBUG_SYNC },
|
||||
{ "afbc", PANVK_DEBUG_AFBC },
|
||||
{ "linear", PANVK_DEBUG_LINEAR },
|
||||
{ "dump", PANVK_DEBUG_DUMP },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
{"startup", PANVK_DEBUG_STARTUP}, {"nir", PANVK_DEBUG_NIR},
|
||||
{"trace", PANVK_DEBUG_TRACE}, {"sync", PANVK_DEBUG_SYNC},
|
||||
{"afbc", PANVK_DEBUG_AFBC}, {"linear", PANVK_DEBUG_LINEAR},
|
||||
{"dump", PANVK_DEBUG_DUMP}, {NULL, 0}};
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
#define PANVK_USE_WSI_PLATFORM
|
||||
|
|
@ -132,8 +126,8 @@ static const struct debug_control panvk_debug_options[] = {
|
|||
VkResult
|
||||
panvk_EnumerateInstanceVersion(uint32_t *pApiVersion)
|
||||
{
|
||||
*pApiVersion = PANVK_API_VERSION;
|
||||
return VK_SUCCESS;
|
||||
*pApiVersion = PANVK_API_VERSION;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static const struct vk_instance_extension_table panvk_instance_extensions = {
|
||||
|
|
@ -153,7 +147,7 @@ static void
|
|||
panvk_get_device_extensions(const struct panvk_physical_device *device,
|
||||
struct vk_device_extension_table *ext)
|
||||
{
|
||||
*ext = (struct vk_device_extension_table) {
|
||||
*ext = (struct vk_device_extension_table){
|
||||
.KHR_copy_commands2 = true,
|
||||
.KHR_storage_buffer_storage_class = true,
|
||||
.KHR_descriptor_update_template = true,
|
||||
|
|
@ -202,7 +196,7 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
|
||||
|
||||
pAllocator = pAllocator ? : vk_default_allocator();
|
||||
pAllocator = pAllocator ?: vk_default_allocator();
|
||||
instance = vk_zalloc(pAllocator, sizeof(*instance), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||
if (!instance)
|
||||
|
|
@ -210,17 +204,12 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
|
||||
struct vk_instance_dispatch_table dispatch_table;
|
||||
|
||||
vk_instance_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&panvk_instance_entrypoints,
|
||||
true);
|
||||
vk_instance_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&wsi_instance_entrypoints,
|
||||
false);
|
||||
result = vk_instance_init(&instance->vk,
|
||||
&panvk_instance_extensions,
|
||||
&dispatch_table,
|
||||
pCreateInfo,
|
||||
pAllocator);
|
||||
vk_instance_dispatch_table_from_entrypoints(
|
||||
&dispatch_table, &panvk_instance_entrypoints, true);
|
||||
vk_instance_dispatch_table_from_entrypoints(
|
||||
&dispatch_table, &wsi_instance_entrypoints, false);
|
||||
result = vk_instance_init(&instance->vk, &panvk_instance_extensions,
|
||||
&dispatch_table, pCreateInfo, pAllocator);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free(pAllocator, instance);
|
||||
return vk_error(NULL, result);
|
||||
|
|
@ -230,8 +219,8 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
panvk_physical_device_try_create;
|
||||
instance->vk.physical_devices.destroy = panvk_destroy_physical_device;
|
||||
|
||||
instance->debug_flags = parse_debug_string(getenv("PANVK_DEBUG"),
|
||||
panvk_debug_options);
|
||||
instance->debug_flags =
|
||||
parse_debug_string(getenv("PANVK_DEBUG"), panvk_debug_options);
|
||||
|
||||
if (instance->debug_flags & PANVK_DEBUG_STARTUP)
|
||||
panvk_logi("Created an instance");
|
||||
|
|
@ -268,9 +257,10 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
int master_fd = -1;
|
||||
|
||||
if (!getenv("PAN_I_WANT_A_BROKEN_VULKAN_DRIVER")) {
|
||||
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"WARNING: panvk is not a conformant vulkan implementation, "
|
||||
"pass PAN_I_WANT_A_BROKEN_VULKAN_DRIVER=1 if you know what you're doing.");
|
||||
return vk_errorf(
|
||||
instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"WARNING: panvk is not a conformant vulkan implementation, "
|
||||
"pass PAN_I_WANT_A_BROKEN_VULKAN_DRIVER=1 if you know what you're doing.");
|
||||
}
|
||||
|
||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
||||
|
|
@ -291,7 +281,8 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
drmFreeVersion(version);
|
||||
close(fd);
|
||||
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"device %s does not use the panfrost kernel driver", path);
|
||||
"device %s does not use the panfrost kernel driver",
|
||||
path);
|
||||
}
|
||||
|
||||
drmFreeVersion(version);
|
||||
|
|
@ -303,16 +294,13 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
panvk_get_device_extensions(device, &supported_extensions);
|
||||
|
||||
struct vk_physical_device_dispatch_table dispatch_table;
|
||||
vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&panvk_physical_device_entrypoints,
|
||||
true);
|
||||
vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&wsi_physical_device_entrypoints,
|
||||
false);
|
||||
vk_physical_device_dispatch_table_from_entrypoints(
|
||||
&dispatch_table, &panvk_physical_device_entrypoints, true);
|
||||
vk_physical_device_dispatch_table_from_entrypoints(
|
||||
&dispatch_table, &wsi_physical_device_entrypoints, false);
|
||||
|
||||
result = vk_physical_device_init(&device->vk, &instance->vk,
|
||||
&supported_extensions,
|
||||
&dispatch_table);
|
||||
&supported_extensions, &dispatch_table);
|
||||
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_error(instance, result);
|
||||
|
|
@ -340,8 +328,7 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
|
||||
if (device->pdev.arch <= 5) {
|
||||
result = vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"%s not supported",
|
||||
device->pdev.model->name);
|
||||
"%s not supported", device->pdev.model->name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -614,11 +601,12 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
.maxFragmentInputComponents = 128,
|
||||
.maxFragmentOutputAttachments = 8,
|
||||
.maxFragmentDualSrcAttachments = 1,
|
||||
.maxFragmentCombinedOutputResources = MAX_RTS + max_descriptor_set_size * 2,
|
||||
.maxFragmentCombinedOutputResources =
|
||||
MAX_RTS + max_descriptor_set_size * 2,
|
||||
.maxComputeSharedMemorySize = 32768,
|
||||
.maxComputeWorkGroupCount = { 65535, 65535, 65535 },
|
||||
.maxComputeWorkGroupCount = {65535, 65535, 65535},
|
||||
.maxComputeWorkGroupInvocations = 2048,
|
||||
.maxComputeWorkGroupSize = { 2048, 2048, 2048 },
|
||||
.maxComputeWorkGroupSize = {2048, 2048, 2048},
|
||||
.subPixelPrecisionBits = 4 /* FIXME */,
|
||||
.subTexelPrecisionBits = 4 /* FIXME */,
|
||||
.mipmapPrecisionBits = 4 /* FIXME */,
|
||||
|
|
@ -627,8 +615,8 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
.maxSamplerLodBias = 16,
|
||||
.maxSamplerAnisotropy = 16,
|
||||
.maxViewports = MAX_VIEWPORTS,
|
||||
.maxViewportDimensions = { (1 << 14), (1 << 14) },
|
||||
.viewportBoundsRange = { INT16_MIN, INT16_MAX },
|
||||
.maxViewportDimensions = {(1 << 14), (1 << 14)},
|
||||
.viewportBoundsRange = {INT16_MIN, INT16_MAX},
|
||||
.viewportSubPixelBits = 8,
|
||||
.minMemoryMapAlignment = 4096, /* A page */
|
||||
.minTexelBufferOffsetAlignment = 64,
|
||||
|
|
@ -661,8 +649,8 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
.maxCullDistances = 8,
|
||||
.maxCombinedClipAndCullDistances = 8,
|
||||
.discreteQueuePriorities = 1,
|
||||
.pointSizeRange = { 0.125, 4095.9375 },
|
||||
.lineWidthRange = { 0.0, 7.9921875 },
|
||||
.pointSizeRange = {0.125, 4095.9375},
|
||||
.lineWidthRange = {0.0, 7.9921875},
|
||||
.pointSizeGranularity = (1.0 / 16.0),
|
||||
.lineWidthGranularity = (1.0 / 128.0),
|
||||
.strictLines = false, /* FINISHME */
|
||||
|
|
@ -672,31 +660,32 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
.nonCoherentAtomSize = 64,
|
||||
};
|
||||
|
||||
pProperties->properties = (VkPhysicalDeviceProperties) {
|
||||
pProperties->properties = (VkPhysicalDeviceProperties){
|
||||
.apiVersion = PANVK_API_VERSION,
|
||||
.driverVersion = vk_get_driver_version(),
|
||||
.vendorID = 0, /* TODO */
|
||||
.deviceID = 0,
|
||||
.deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
|
||||
.limits = limits,
|
||||
.sparseProperties = { 0 },
|
||||
.sparseProperties = {0},
|
||||
};
|
||||
|
||||
strcpy(pProperties->properties.deviceName, pdevice->name);
|
||||
memcpy(pProperties->properties.pipelineCacheUUID, pdevice->cache_uuid, VK_UUID_SIZE);
|
||||
memcpy(pProperties->properties.pipelineCacheUUID, pdevice->cache_uuid,
|
||||
VK_UUID_SIZE);
|
||||
|
||||
VkPhysicalDeviceVulkan11Properties core_1_1 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES,
|
||||
.deviceLUIDValid = false,
|
||||
.pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES,
|
||||
.maxMultiviewViewCount = 0,
|
||||
.maxMultiviewInstanceIndex = 0,
|
||||
.protectedNoFault = false,
|
||||
.deviceLUIDValid = false,
|
||||
.pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES,
|
||||
.maxMultiviewViewCount = 0,
|
||||
.maxMultiviewInstanceIndex = 0,
|
||||
.protectedNoFault = false,
|
||||
/* Make sure everything is addressable by a signed 32-bit int, and
|
||||
* our largest descriptors are 96 bytes. */
|
||||
.maxPerSetDescriptors = (1ull << 31) / 96,
|
||||
.maxPerSetDescriptors = (1ull << 31) / 96,
|
||||
/* Our buffer size fields allow only this much */
|
||||
.maxMemoryAllocationSize = 0xFFFFFFFFull,
|
||||
.maxMemoryAllocationSize = 0xFFFFFFFFull,
|
||||
};
|
||||
memcpy(core_1_1.driverUUID, pdevice->driver_uuid, VK_UUID_SIZE);
|
||||
memcpy(core_1_1.deviceUUID, pdevice->device_uuid, VK_UUID_SIZE);
|
||||
|
|
@ -720,7 +709,8 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
|
||||
switch (ext->sType) {
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: {
|
||||
VkPhysicalDevicePushDescriptorPropertiesKHR *properties = (VkPhysicalDevicePushDescriptorPropertiesKHR *)ext;
|
||||
VkPhysicalDevicePushDescriptorPropertiesKHR *properties =
|
||||
(VkPhysicalDevicePushDescriptorPropertiesKHR *)ext;
|
||||
properties->maxPushDescriptors = MAX_PUSH_DESCRIPTORS;
|
||||
break;
|
||||
}
|
||||
|
|
@ -738,19 +728,19 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||
}
|
||||
|
||||
static const VkQueueFamilyProperties panvk_queue_family_properties = {
|
||||
.queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT,
|
||||
.queueFlags =
|
||||
VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT,
|
||||
.queueCount = 1,
|
||||
.timestampValidBits = 64,
|
||||
.minImageTransferGranularity = { 1, 1, 1 },
|
||||
.minImageTransferGranularity = {1, 1, 1},
|
||||
};
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice,
|
||||
uint32_t *pQueueFamilyPropertyCount,
|
||||
VkQueueFamilyProperties2 *pQueueFamilyProperties)
|
||||
panvk_GetPhysicalDeviceQueueFamilyProperties2(
|
||||
VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
|
||||
VkQueueFamilyProperties2 *pQueueFamilyProperties)
|
||||
{
|
||||
VK_OUTARRAY_MAKE_TYPED(VkQueueFamilyProperties2, out,
|
||||
pQueueFamilyProperties,
|
||||
VK_OUTARRAY_MAKE_TYPED(VkQueueFamilyProperties2, out, pQueueFamilyProperties,
|
||||
pQueueFamilyPropertyCount);
|
||||
|
||||
vk_outarray_append_typed(VkQueueFamilyProperties2, &out, p)
|
||||
|
|
@ -780,10 +770,11 @@ panvk_get_system_heap_size()
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
|
||||
panvk_GetPhysicalDeviceMemoryProperties2(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
|
||||
{
|
||||
pMemoryProperties->memoryProperties = (VkPhysicalDeviceMemoryProperties) {
|
||||
pMemoryProperties->memoryProperties = (VkPhysicalDeviceMemoryProperties){
|
||||
.memoryHeapCount = 1,
|
||||
.memoryHeaps[0].size = panvk_get_system_heap_size(),
|
||||
.memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
|
||||
|
|
@ -796,10 +787,8 @@ panvk_GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice,
|
|||
}
|
||||
|
||||
static VkResult
|
||||
panvk_queue_init(struct panvk_device *device,
|
||||
struct panvk_queue *queue,
|
||||
int idx,
|
||||
const VkDeviceQueueCreateInfo *create_info)
|
||||
panvk_queue_init(struct panvk_device *device, struct panvk_queue *queue,
|
||||
int idx, const VkDeviceQueueCreateInfo *create_info)
|
||||
{
|
||||
const struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
|
||||
|
|
@ -819,9 +808,14 @@ panvk_queue_init(struct panvk_device *device,
|
|||
}
|
||||
|
||||
switch (pdev->arch) {
|
||||
case 6: queue->vk.driver_submit = panvk_v6_queue_submit; break;
|
||||
case 7: queue->vk.driver_submit = panvk_v7_queue_submit; break;
|
||||
default: unreachable("Invalid arch");
|
||||
case 6:
|
||||
queue->vk.driver_submit = panvk_v6_queue_submit;
|
||||
break;
|
||||
case 7:
|
||||
queue->vk.driver_submit = panvk_v7_queue_submit;
|
||||
break;
|
||||
default:
|
||||
unreachable("Invalid arch");
|
||||
}
|
||||
|
||||
queue->sync = create.handle;
|
||||
|
|
@ -837,8 +831,7 @@ panvk_queue_finish(struct panvk_queue *queue)
|
|||
VkResult
|
||||
panvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
const VkDeviceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDevice *pDevice)
|
||||
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice);
|
||||
VkResult result;
|
||||
|
|
@ -870,30 +863,23 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
* in the main device-level dispatch table with
|
||||
* vk_cmd_enqueue_unless_primary_Cmd*.
|
||||
*/
|
||||
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&vk_cmd_enqueue_unless_primary_device_entrypoints,
|
||||
true);
|
||||
vk_device_dispatch_table_from_entrypoints(
|
||||
&dispatch_table, &vk_cmd_enqueue_unless_primary_device_entrypoints, true);
|
||||
|
||||
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
dev_entrypoints,
|
||||
vk_device_dispatch_table_from_entrypoints(&dispatch_table, dev_entrypoints,
|
||||
false);
|
||||
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&panvk_device_entrypoints,
|
||||
false);
|
||||
&panvk_device_entrypoints, false);
|
||||
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
|
||||
&wsi_device_entrypoints,
|
||||
false);
|
||||
&wsi_device_entrypoints, false);
|
||||
|
||||
/* Populate our primary cmd_dispatch table. */
|
||||
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
|
||||
dev_entrypoints,
|
||||
true);
|
||||
dev_entrypoints, true);
|
||||
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
|
||||
&panvk_device_entrypoints,
|
||||
false);
|
||||
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
|
||||
&vk_common_device_entrypoints,
|
||||
false);
|
||||
&panvk_device_entrypoints, false);
|
||||
vk_device_dispatch_table_from_entrypoints(
|
||||
&device->cmd_dispatch, &vk_common_device_entrypoints, false);
|
||||
|
||||
result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table,
|
||||
pCreateInfo, pAllocator);
|
||||
|
|
@ -920,8 +906,8 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
uint32_t qfi = queue_create->queueFamilyIndex;
|
||||
device->queues[qfi] =
|
||||
vk_alloc(&device->vk.alloc,
|
||||
queue_create->queueCount * sizeof(struct panvk_queue),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
queue_create->queueCount * sizeof(struct panvk_queue), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!device->queues[qfi]) {
|
||||
result = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -933,8 +919,8 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
device->queue_count[qfi] = queue_create->queueCount;
|
||||
|
||||
for (unsigned q = 0; q < queue_create->queueCount; q++) {
|
||||
result = panvk_queue_init(device, &device->queues[qfi][q], q,
|
||||
queue_create);
|
||||
result =
|
||||
panvk_queue_init(device, &device->queues[qfi][q], q, queue_create);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -991,7 +977,7 @@ panvk_QueueWaitIdle(VkQueue _queue)
|
|||
|
||||
const struct panfrost_device *pdev = &queue->device->physical_device->pdev;
|
||||
struct drm_syncobj_wait wait = {
|
||||
.handles = (uint64_t) (uintptr_t)(&queue->sync),
|
||||
.handles = (uint64_t)(uintptr_t)(&queue->sync),
|
||||
.count_handles = 1,
|
||||
.timeout_nsec = INT64_MAX,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL,
|
||||
|
|
@ -1012,16 +998,15 @@ panvk_EnumerateInstanceExtensionProperties(const char *pLayerName,
|
|||
if (pLayerName)
|
||||
return vk_error(NULL, VK_ERROR_LAYER_NOT_PRESENT);
|
||||
|
||||
return vk_enumerate_instance_extension_properties(&panvk_instance_extensions,
|
||||
pPropertyCount, pProperties);
|
||||
return vk_enumerate_instance_extension_properties(
|
||||
&panvk_instance_extensions, pPropertyCount, pProperties);
|
||||
}
|
||||
|
||||
PFN_vkVoidFunction
|
||||
panvk_GetInstanceProcAddr(VkInstance _instance, const char *pName)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_instance, instance, _instance);
|
||||
return vk_instance_get_proc_addr(&instance->vk,
|
||||
&panvk_instance_entrypoints,
|
||||
return vk_instance_get_proc_addr(&instance->vk, &panvk_instance_entrypoints,
|
||||
pName);
|
||||
}
|
||||
|
||||
|
|
@ -1044,12 +1029,10 @@ vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
|
|||
*/
|
||||
PUBLIC
|
||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
|
||||
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance,
|
||||
const char* pName);
|
||||
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance, const char *pName);
|
||||
|
||||
PFN_vkVoidFunction
|
||||
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance,
|
||||
const char* pName)
|
||||
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance, const char *pName)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_instance, instance, _instance);
|
||||
|
||||
|
|
@ -1079,17 +1062,15 @@ panvk_AllocateMemory(VkDevice _device,
|
|||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
const VkImportMemoryFdInfoKHR *fd_info =
|
||||
vk_find_struct_const(pAllocateInfo->pNext,
|
||||
IMPORT_MEMORY_FD_INFO_KHR);
|
||||
vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHR);
|
||||
|
||||
if (fd_info && !fd_info->handleType)
|
||||
fd_info = NULL;
|
||||
|
||||
if (fd_info) {
|
||||
assert(fd_info->handleType ==
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
fd_info->handleType ==
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
|
||||
assert(
|
||||
fd_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
fd_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
|
||||
|
||||
/*
|
||||
* TODO Importing the same fd twice gives us the same handle without
|
||||
|
|
@ -1113,8 +1094,7 @@ panvk_AllocateMemory(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_FreeMemory(VkDevice _device,
|
||||
VkDeviceMemory _mem,
|
||||
panvk_FreeMemory(VkDevice _device, VkDeviceMemory _mem,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1128,12 +1108,8 @@ panvk_FreeMemory(VkDevice _device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_MapMemory(VkDevice _device,
|
||||
VkDeviceMemory _memory,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size,
|
||||
VkMemoryMapFlags flags,
|
||||
void **ppData)
|
||||
panvk_MapMemory(VkDevice _device, VkDeviceMemory _memory, VkDeviceSize offset,
|
||||
VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_device_memory, mem, _memory);
|
||||
|
|
@ -1162,16 +1138,14 @@ panvk_UnmapMemory(VkDevice _device, VkDeviceMemory _memory)
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_FlushMappedMemoryRanges(VkDevice _device,
|
||||
uint32_t memoryRangeCount,
|
||||
panvk_FlushMappedMemoryRanges(VkDevice _device, uint32_t memoryRangeCount,
|
||||
const VkMappedMemoryRange *pMemoryRanges)
|
||||
{
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
panvk_InvalidateMappedMemoryRanges(VkDevice _device,
|
||||
uint32_t memoryRangeCount,
|
||||
panvk_InvalidateMappedMemoryRanges(VkDevice _device, uint32_t memoryRangeCount,
|
||||
const VkMappedMemoryRange *pMemoryRanges)
|
||||
{
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -1194,8 +1168,8 @@ panvk_GetBufferMemoryRequirements2(VkDevice device,
|
|||
|
||||
void
|
||||
panvk_GetImageMemoryRequirements2(VkDevice device,
|
||||
const VkImageMemoryRequirementsInfo2 *pInfo,
|
||||
VkMemoryRequirements2 *pMemoryRequirements)
|
||||
const VkImageMemoryRequirementsInfo2 *pInfo,
|
||||
VkMemoryRequirements2 *pMemoryRequirements)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_image, image, pInfo->image);
|
||||
|
||||
|
|
@ -1208,25 +1182,23 @@ panvk_GetImageMemoryRequirements2(VkDevice device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetImageSparseMemoryRequirements2(VkDevice device,
|
||||
const VkImageSparseMemoryRequirementsInfo2 *pInfo,
|
||||
uint32_t *pSparseMemoryRequirementCount,
|
||||
VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements)
|
||||
panvk_GetImageSparseMemoryRequirements2(
|
||||
VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo,
|
||||
uint32_t *pSparseMemoryRequirementCount,
|
||||
VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_GetDeviceMemoryCommitment(VkDevice device,
|
||||
VkDeviceMemory memory,
|
||||
panvk_GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory,
|
||||
VkDeviceSize *pCommittedMemoryInBytes)
|
||||
{
|
||||
*pCommittedMemoryInBytes = 0;
|
||||
}
|
||||
|
||||
VkResult
|
||||
panvk_BindBufferMemory2(VkDevice device,
|
||||
uint32_t bindInfoCount,
|
||||
panvk_BindBufferMemory2(VkDevice device, uint32_t bindInfoCount,
|
||||
const VkBindBufferMemoryInfo *pBindInfos)
|
||||
{
|
||||
for (uint32_t i = 0; i < bindInfoCount; ++i) {
|
||||
|
|
@ -1244,8 +1216,7 @@ panvk_BindBufferMemory2(VkDevice device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_BindImageMemory2(VkDevice device,
|
||||
uint32_t bindInfoCount,
|
||||
panvk_BindImageMemory2(VkDevice device, uint32_t bindInfoCount,
|
||||
const VkBindImageMemoryInfo *pBindInfos)
|
||||
{
|
||||
for (uint32_t i = 0; i < bindInfoCount; ++i) {
|
||||
|
|
@ -1257,14 +1228,18 @@ panvk_BindImageMemory2(VkDevice device,
|
|||
image->pimage.data.offset = pBindInfos[i].memoryOffset;
|
||||
/* Reset the AFBC headers */
|
||||
if (drm_is_afbc(image->pimage.layout.modifier)) {
|
||||
void *base = image->pimage.data.bo->ptr.cpu + image->pimage.data.offset;
|
||||
void *base =
|
||||
image->pimage.data.bo->ptr.cpu + image->pimage.data.offset;
|
||||
|
||||
for (unsigned layer = 0; layer < image->pimage.layout.array_size; layer++) {
|
||||
for (unsigned level = 0; level < image->pimage.layout.nr_slices; level++) {
|
||||
for (unsigned layer = 0; layer < image->pimage.layout.array_size;
|
||||
layer++) {
|
||||
for (unsigned level = 0; level < image->pimage.layout.nr_slices;
|
||||
level++) {
|
||||
void *header = base +
|
||||
(layer * image->pimage.layout.array_stride) +
|
||||
image->pimage.layout.slices[level].offset;
|
||||
memset(header, 0, image->pimage.layout.slices[level].afbc.header_size);
|
||||
memset(header, 0,
|
||||
image->pimage.layout.slices[level].afbc.header_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1278,16 +1253,13 @@ panvk_BindImageMemory2(VkDevice device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_CreateEvent(VkDevice _device,
|
||||
const VkEventCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkEvent *pEvent)
|
||||
panvk_CreateEvent(VkDevice _device, const VkEventCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
const struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
struct panvk_event *event =
|
||||
vk_object_zalloc(&device->vk, pAllocator, sizeof(*event),
|
||||
VK_OBJECT_TYPE_EVENT);
|
||||
struct panvk_event *event = vk_object_zalloc(
|
||||
&device->vk, pAllocator, sizeof(*event), VK_OBJECT_TYPE_EVENT);
|
||||
if (!event)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
@ -1306,8 +1278,7 @@ panvk_CreateEvent(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyEvent(VkDevice _device,
|
||||
VkEvent _event,
|
||||
panvk_DestroyEvent(VkDevice _device, VkEvent _event,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1317,7 +1288,7 @@ panvk_DestroyEvent(VkDevice _device,
|
|||
if (!event)
|
||||
return;
|
||||
|
||||
struct drm_syncobj_destroy destroy = { .handle = event->syncobj };
|
||||
struct drm_syncobj_destroy destroy = {.handle = event->syncobj};
|
||||
drmIoctl(pdev->fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
|
||||
|
||||
vk_object_free(&device->vk, pAllocator, event);
|
||||
|
|
@ -1332,7 +1303,7 @@ panvk_GetEventStatus(VkDevice _device, VkEvent _event)
|
|||
bool signaled;
|
||||
|
||||
struct drm_syncobj_wait wait = {
|
||||
.handles = (uintptr_t) &event->syncobj,
|
||||
.handles = (uintptr_t)&event->syncobj,
|
||||
.count_handles = 1,
|
||||
.timeout_nsec = 0,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
|
|
@ -1360,9 +1331,8 @@ panvk_SetEvent(VkDevice _device, VkEvent _event)
|
|||
const struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t) (uintptr_t) &event->syncobj,
|
||||
.count_handles = 1
|
||||
};
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
/* This is going to just replace the fence for this syncobj with one that
|
||||
* is already in signaled state. This won't be a problem because the spec
|
||||
|
|
@ -1373,7 +1343,7 @@ panvk_SetEvent(VkDevice _device, VkEvent _event)
|
|||
if (drmIoctl(pdev->fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
@ -1384,29 +1354,26 @@ panvk_ResetEvent(VkDevice _device, VkEvent _event)
|
|||
const struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t) (uintptr_t) &event->syncobj,
|
||||
.count_handles = 1
|
||||
};
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
if (drmIoctl(pdev->fd, DRM_IOCTL_SYNCOBJ_RESET, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
panvk_CreateBuffer(VkDevice _device,
|
||||
const VkBufferCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkBuffer *pBuffer)
|
||||
panvk_CreateBuffer(VkDevice _device, const VkBufferCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
struct panvk_buffer *buffer;
|
||||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
|
||||
|
||||
buffer = vk_buffer_create(&device->vk, pCreateInfo,
|
||||
pAllocator, sizeof(*buffer));
|
||||
buffer =
|
||||
vk_buffer_create(&device->vk, pCreateInfo, pAllocator, sizeof(*buffer));
|
||||
if (buffer == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
@ -1416,8 +1383,7 @@ panvk_CreateBuffer(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyBuffer(VkDevice _device,
|
||||
VkBuffer _buffer,
|
||||
panvk_DestroyBuffer(VkDevice _device, VkBuffer _buffer,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1462,8 +1428,7 @@ panvk_CreateFramebuffer(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyFramebuffer(VkDevice _device,
|
||||
VkFramebuffer _fb,
|
||||
panvk_DestroyFramebuffer(VkDevice _device, VkFramebuffer _fb,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1474,8 +1439,7 @@ panvk_DestroyFramebuffer(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroySampler(VkDevice _device,
|
||||
VkSampler _sampler,
|
||||
panvk_DestroySampler(VkDevice _device, VkSampler _sampler,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1542,8 +1506,7 @@ vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_GetMemoryFdKHR(VkDevice _device,
|
||||
const VkMemoryGetFdInfoKHR *pGetFdInfo,
|
||||
panvk_GetMemoryFdKHR(VkDevice _device, const VkMemoryGetFdInfoKHR *pGetFdInfo,
|
||||
int *pFd)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1552,8 +1515,9 @@ panvk_GetMemoryFdKHR(VkDevice _device,
|
|||
assert(pGetFdInfo->sType == VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR);
|
||||
|
||||
/* At the moment, we support only the below handle types. */
|
||||
assert(pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
|
||||
assert(
|
||||
pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
|
||||
|
||||
int prime_fd = panfrost_bo_export(memory->bo);
|
||||
if (prime_fd < 0)
|
||||
|
|
@ -1575,12 +1539,15 @@ panvk_GetMemoryFdPropertiesKHR(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo,
|
||||
VkExternalSemaphoreProperties *pExternalSemaphoreProperties)
|
||||
panvk_GetPhysicalDeviceExternalSemaphoreProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo,
|
||||
VkExternalSemaphoreProperties *pExternalSemaphoreProperties)
|
||||
{
|
||||
if ((pExternalSemaphoreInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
pExternalSemaphoreInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT)) {
|
||||
if ((pExternalSemaphoreInfo->handleType ==
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT ||
|
||||
pExternalSemaphoreInfo->handleType ==
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT)) {
|
||||
pExternalSemaphoreProperties->exportFromImportedHandleTypes =
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT |
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
|
||||
|
|
@ -1598,9 +1565,10 @@ panvk_GetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevi
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo,
|
||||
VkExternalFenceProperties *pExternalFenceProperties)
|
||||
panvk_GetPhysicalDeviceExternalFenceProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo,
|
||||
VkExternalFenceProperties *pExternalFenceProperties)
|
||||
{
|
||||
pExternalFenceProperties->exportFromImportedHandleTypes = 0;
|
||||
pExternalFenceProperties->compatibleHandleTypes = 0;
|
||||
|
|
|
|||
|
|
@ -27,18 +27,17 @@
|
|||
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "panfrost/lib/pan_texture.h"
|
||||
#include "util/format_r11g11b10f.h"
|
||||
#include "util/format_srgb.h"
|
||||
#include "util/half_float.h"
|
||||
#include "vulkan/util/vk_format.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
#include "panfrost/lib/pan_texture.h"
|
||||
|
||||
static void
|
||||
get_format_properties(struct panvk_physical_device *physical_device,
|
||||
VkFormat format,
|
||||
VkFormatProperties *out_properties)
|
||||
VkFormat format, VkFormatProperties *out_properties)
|
||||
{
|
||||
struct panfrost_device *pdev = &physical_device->pdev;
|
||||
VkFormatFeatureFlags tex = 0, buffer = 0;
|
||||
|
|
@ -59,8 +58,8 @@ get_format_properties(struct panvk_physical_device *physical_device,
|
|||
if (util_format_is_compressed(pfmt))
|
||||
goto end;
|
||||
|
||||
buffer |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
|
||||
VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
|
||||
buffer |=
|
||||
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
|
||||
|
||||
if (fmt.bind & PIPE_BIND_VERTEX_BUFFER)
|
||||
buffer |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
|
||||
|
|
@ -73,8 +72,7 @@ get_format_properties(struct panvk_physical_device *physical_device,
|
|||
VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT;
|
||||
|
||||
/* Integer formats only support nearest filtering */
|
||||
if (!util_format_is_scaled(pfmt) &&
|
||||
!util_format_is_pure_integer(pfmt))
|
||||
if (!util_format_is_scaled(pfmt) && !util_format_is_pure_integer(pfmt))
|
||||
tex |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
|
||||
buffer |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
|
||||
|
|
@ -95,7 +93,7 @@ get_format_properties(struct panvk_physical_device *physical_device,
|
|||
}
|
||||
|
||||
if (fmt.bind & PIPE_BIND_DEPTH_STENCIL)
|
||||
tex |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
tex |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
end:
|
||||
out_properties->linearTilingFeatures = tex;
|
||||
|
|
@ -105,8 +103,8 @@ end:
|
|||
|
||||
void
|
||||
panvk_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
VkFormatProperties *pFormatProperties)
|
||||
VkFormat format,
|
||||
VkFormatProperties *pFormatProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice);
|
||||
|
||||
|
|
@ -123,14 +121,16 @@ panvk_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
get_format_properties(physical_device, format,
|
||||
&pFormatProperties->formatProperties);
|
||||
|
||||
VkDrmFormatModifierPropertiesListEXT *list =
|
||||
vk_find_struct(pFormatProperties->pNext, DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
|
||||
VkDrmFormatModifierPropertiesListEXT *list = vk_find_struct(
|
||||
pFormatProperties->pNext, DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
|
||||
if (list) {
|
||||
VK_OUTARRAY_MAKE_TYPED(VkDrmFormatModifierPropertiesEXT, out,
|
||||
list->pDrmFormatModifierProperties,
|
||||
&list->drmFormatModifierCount);
|
||||
|
||||
vk_outarray_append_typed(VkDrmFormatModifierProperties2EXT, &out, mod_props) {
|
||||
vk_outarray_append_typed(VkDrmFormatModifierProperties2EXT, &out,
|
||||
mod_props)
|
||||
{
|
||||
mod_props->drmFormatModifier = DRM_FORMAT_MOD_LINEAR;
|
||||
mod_props->drmFormatModifierPlaneCount = 1;
|
||||
}
|
||||
|
|
@ -170,7 +170,8 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
|||
if (util_format_is_depth_or_stencil(format))
|
||||
goto unsupported;
|
||||
|
||||
assert(format_props.optimalTilingFeatures == format_props.linearTilingFeatures);
|
||||
assert(format_props.optimalTilingFeatures ==
|
||||
format_props.linearTilingFeatures);
|
||||
FALLTHROUGH;
|
||||
case VK_IMAGE_TILING_OPTIMAL:
|
||||
format_feature_flags = format_props.optimalTilingFeatures;
|
||||
|
|
@ -247,7 +248,7 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
|||
}
|
||||
}
|
||||
|
||||
*pImageFormatProperties = (VkImageFormatProperties) {
|
||||
*pImageFormatProperties = (VkImageFormatProperties){
|
||||
.maxExtent = maxExtent,
|
||||
.maxMipLevels = maxMipLevels,
|
||||
.maxArrayLayers = maxArraySize,
|
||||
|
|
@ -264,8 +265,8 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
|||
|
||||
return VK_SUCCESS;
|
||||
unsupported:
|
||||
*pImageFormatProperties = (VkImageFormatProperties) {
|
||||
.maxExtent = { 0, 0, 0 },
|
||||
*pImageFormatProperties = (VkImageFormatProperties){
|
||||
.maxExtent = {0, 0, 0},
|
||||
.maxMipLevels = 0,
|
||||
.maxArrayLayers = 0,
|
||||
.sampleCounts = 0,
|
||||
|
|
@ -275,15 +276,12 @@ unsupported:
|
|||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
VkResult
|
||||
panvk_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
VkImageType type,
|
||||
VkImageTiling tiling,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageCreateFlags createFlags,
|
||||
VkImageFormatProperties *pImageFormatProperties)
|
||||
panvk_GetPhysicalDeviceImageFormatProperties(
|
||||
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
|
||||
VkImageTiling tiling, VkImageUsageFlags usage,
|
||||
VkImageCreateFlags createFlags,
|
||||
VkImageFormatProperties *pImageFormatProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice);
|
||||
|
||||
|
|
@ -302,10 +300,11 @@ panvk_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice,
|
|||
}
|
||||
|
||||
static VkResult
|
||||
panvk_get_external_image_format_properties(const struct panvk_physical_device *physical_device,
|
||||
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
|
||||
VkExternalMemoryHandleTypeFlagBits handleType,
|
||||
VkExternalMemoryProperties *external_properties)
|
||||
panvk_get_external_image_format_properties(
|
||||
const struct panvk_physical_device *physical_device,
|
||||
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
|
||||
VkExternalMemoryHandleTypeFlagBits handleType,
|
||||
VkExternalMemoryProperties *external_properties)
|
||||
{
|
||||
VkExternalMemoryFeatureFlagBits flags = 0;
|
||||
VkExternalMemoryHandleTypeFlags export_flags = 0;
|
||||
|
|
@ -331,9 +330,10 @@ panvk_get_external_image_format_properties(const struct panvk_physical_device *p
|
|||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
|
||||
break;
|
||||
default:
|
||||
return vk_errorf(physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
|
||||
"VkExternalMemoryTypeFlagBits(0x%x) unsupported for VkImageType(%d)",
|
||||
handleType, pImageFormatInfo->type);
|
||||
return vk_errorf(
|
||||
physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
|
||||
"VkExternalMemoryTypeFlagBits(0x%x) unsupported for VkImageType(%d)",
|
||||
handleType, pImageFormatInfo->type);
|
||||
}
|
||||
break;
|
||||
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT:
|
||||
|
|
@ -346,7 +346,7 @@ panvk_get_external_image_format_properties(const struct panvk_physical_device *p
|
|||
handleType);
|
||||
}
|
||||
|
||||
*external_properties = (VkExternalMemoryProperties) {
|
||||
*external_properties = (VkExternalMemoryProperties){
|
||||
.externalMemoryFeatures = flags,
|
||||
.exportFromImportedHandleTypes = export_flags,
|
||||
.compatibleHandleTypes = compat_flags,
|
||||
|
|
@ -356,9 +356,10 @@ panvk_get_external_image_format_properties(const struct panvk_physical_device *p
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceImageFormatInfo2 *base_info,
|
||||
VkImageFormatProperties2 *base_props)
|
||||
panvk_GetPhysicalDeviceImageFormatProperties2(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceImageFormatInfo2 *base_info,
|
||||
VkImageFormatProperties2 *base_props)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice);
|
||||
const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
|
||||
|
|
@ -380,10 +381,10 @@ panvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
{
|
||||
switch (s->sType) {
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
|
||||
external_info = (const void *) s;
|
||||
external_info = (const void *)s;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT:
|
||||
image_view_info = (const void *) s;
|
||||
image_view_info = (const void *)s;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -395,13 +396,13 @@ panvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
{
|
||||
switch (s->sType) {
|
||||
case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
|
||||
external_props = (void *) s;
|
||||
external_props = (void *)s;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT:
|
||||
cubic_props = (void *) s;
|
||||
cubic_props = (void *)s;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
|
||||
ycbcr_props = (void *) s;
|
||||
ycbcr_props = (void *)s;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -415,10 +416,9 @@ panvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
* present and VkExternalImageFormatProperties will be ignored.
|
||||
*/
|
||||
if (external_info && external_info->handleType != 0) {
|
||||
result = panvk_get_external_image_format_properties(physical_device,
|
||||
base_info,
|
||||
external_info->handleType,
|
||||
&external_props->externalMemoryProperties);
|
||||
result = panvk_get_external_image_format_properties(
|
||||
physical_device, base_info, external_info->handleType,
|
||||
&external_props->externalMemoryProperties);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -429,7 +429,8 @@ panvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
*/
|
||||
if ((image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D ||
|
||||
image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY) &&
|
||||
(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT)) {
|
||||
(format_feature_flags &
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT)) {
|
||||
cubic_props->filterCubic = true;
|
||||
cubic_props->filterCubicMinmax = true;
|
||||
} else {
|
||||
|
|
@ -452,40 +453,37 @@ fail:
|
|||
* the implementation for use in vkCreateImage, then all members of
|
||||
* imageFormatProperties will be filled with zero.
|
||||
*/
|
||||
base_props->imageFormatProperties = (VkImageFormatProperties) {};
|
||||
base_props->imageFormatProperties = (VkImageFormatProperties){};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
VkImageType type,
|
||||
uint32_t samples,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageTiling tiling,
|
||||
uint32_t *pNumProperties,
|
||||
VkSparseImageFormatProperties *pProperties)
|
||||
panvk_GetPhysicalDeviceSparseImageFormatProperties(
|
||||
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
|
||||
uint32_t samples, VkImageUsageFlags usage, VkImageTiling tiling,
|
||||
uint32_t *pNumProperties, VkSparseImageFormatProperties *pProperties)
|
||||
{
|
||||
/* Sparse images are not yet supported. */
|
||||
*pNumProperties = 0;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo,
|
||||
uint32_t *pPropertyCount,
|
||||
VkSparseImageFormatProperties2 *pProperties)
|
||||
panvk_GetPhysicalDeviceSparseImageFormatProperties2(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo,
|
||||
uint32_t *pPropertyCount, VkSparseImageFormatProperties2 *pProperties)
|
||||
{
|
||||
/* Sparse images are not yet supported. */
|
||||
*pPropertyCount = 0;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_GetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo,
|
||||
VkExternalBufferProperties *pExternalBufferProperties)
|
||||
panvk_GetPhysicalDeviceExternalBufferProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo,
|
||||
VkExternalBufferProperties *pExternalBufferProperties)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_object.h"
|
||||
#include "vk_util.h"
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
|
||||
unsigned
|
||||
panvk_image_get_plane_size(const struct panvk_image *image, unsigned plane)
|
||||
|
|
@ -53,20 +53,21 @@ static enum mali_texture_dimension
|
|||
panvk_image_type_to_mali_tex_dim(VkImageType type)
|
||||
{
|
||||
switch (type) {
|
||||
case VK_IMAGE_TYPE_1D: return MALI_TEXTURE_DIMENSION_1D;
|
||||
case VK_IMAGE_TYPE_2D: return MALI_TEXTURE_DIMENSION_2D;
|
||||
case VK_IMAGE_TYPE_3D: return MALI_TEXTURE_DIMENSION_3D;
|
||||
default: unreachable("Invalid image type");
|
||||
case VK_IMAGE_TYPE_1D:
|
||||
return MALI_TEXTURE_DIMENSION_1D;
|
||||
case VK_IMAGE_TYPE_2D:
|
||||
return MALI_TEXTURE_DIMENSION_2D;
|
||||
case VK_IMAGE_TYPE_3D:
|
||||
return MALI_TEXTURE_DIMENSION_3D;
|
||||
default:
|
||||
unreachable("Invalid image type");
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
panvk_image_create(VkDevice _device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
VkImage *pImage,
|
||||
uint64_t modifier,
|
||||
const VkSubresourceLayout *plane_layouts)
|
||||
panvk_image_create(VkDevice _device, const VkImageCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *alloc, VkImage *pImage,
|
||||
uint64_t modifier, const VkSubresourceLayout *plane_layouts)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
struct panvk_image *image = NULL;
|
||||
|
|
@ -75,7 +76,7 @@ panvk_image_create(VkDevice _device,
|
|||
if (!image)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
image->pimage.layout = (struct pan_image_layout) {
|
||||
image->pimage.layout = (struct pan_image_layout){
|
||||
.modifier = modifier,
|
||||
.format = vk_format_to_pipe_format(image->vk.format),
|
||||
.dim = panvk_image_type_to_mali_tex_dim(image->vk.image_type),
|
||||
|
|
@ -94,15 +95,16 @@ panvk_image_create(VkDevice _device,
|
|||
}
|
||||
|
||||
static uint64_t
|
||||
panvk_image_select_mod(VkDevice _device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
panvk_image_select_mod(VkDevice _device, const VkImageCreateInfo *pCreateInfo,
|
||||
const VkSubresourceLayout **plane_layouts)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
const struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
enum pipe_format fmt = vk_format_to_pipe_format(pCreateInfo->format);
|
||||
bool noafbc = !(device->physical_device->instance->debug_flags & PANVK_DEBUG_AFBC);
|
||||
bool linear = device->physical_device->instance->debug_flags & PANVK_DEBUG_LINEAR;
|
||||
bool noafbc =
|
||||
!(device->physical_device->instance->debug_flags & PANVK_DEBUG_AFBC);
|
||||
bool linear =
|
||||
device->physical_device->instance->debug_flags & PANVK_DEBUG_LINEAR;
|
||||
|
||||
*plane_layouts = NULL;
|
||||
|
||||
|
|
@ -114,8 +116,9 @@ panvk_image_select_mod(VkDevice _device,
|
|||
vk_find_struct_const(pCreateInfo->pNext,
|
||||
IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT *drm_explicit_info =
|
||||
vk_find_struct_const(pCreateInfo->pNext,
|
||||
IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT);
|
||||
vk_find_struct_const(
|
||||
pCreateInfo->pNext,
|
||||
IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT);
|
||||
|
||||
assert(mod_info || drm_explicit_info);
|
||||
|
||||
|
|
@ -178,8 +181,8 @@ panvk_image_select_mod(VkDevice _device,
|
|||
if (noafbc)
|
||||
return DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;
|
||||
|
||||
uint64_t afbc_type = AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 |
|
||||
AFBC_FORMAT_MOD_SPARSE;
|
||||
uint64_t afbc_type =
|
||||
AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE;
|
||||
|
||||
if (panfrost_afbc_can_ytr(fmt))
|
||||
afbc_type |= AFBC_FORMAT_MOD_YTR;
|
||||
|
|
@ -188,20 +191,19 @@ panvk_image_select_mod(VkDevice _device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_CreateImage(VkDevice device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkImage *pImage)
|
||||
panvk_CreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkImage *pImage)
|
||||
{
|
||||
const VkSubresourceLayout *plane_layouts;
|
||||
uint64_t modifier = panvk_image_select_mod(device, pCreateInfo, &plane_layouts);
|
||||
uint64_t modifier =
|
||||
panvk_image_select_mod(device, pCreateInfo, &plane_layouts);
|
||||
|
||||
return panvk_image_create(device, pCreateInfo, pAllocator, pImage, modifier, plane_layouts);
|
||||
return panvk_image_create(device, pCreateInfo, pAllocator, pImage, modifier,
|
||||
plane_layouts);
|
||||
}
|
||||
|
||||
void
|
||||
panvk_DestroyImage(VkDevice _device,
|
||||
VkImage _image,
|
||||
panvk_DestroyImage(VkDevice _device, VkImage _image,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -229,22 +231,21 @@ panvk_plane_index(VkFormat format, VkImageAspectFlags aspect_mask)
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetImageSubresourceLayout(VkDevice _device,
|
||||
VkImage _image,
|
||||
panvk_GetImageSubresourceLayout(VkDevice _device, VkImage _image,
|
||||
const VkImageSubresource *pSubresource,
|
||||
VkSubresourceLayout *pLayout)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_image, image, _image);
|
||||
|
||||
unsigned plane = panvk_plane_index(image->vk.format, pSubresource->aspectMask);
|
||||
unsigned plane =
|
||||
panvk_plane_index(image->vk.format, pSubresource->aspectMask);
|
||||
assert(plane < PANVK_MAX_PLANES);
|
||||
|
||||
const struct pan_image_slice_layout *slice_layout =
|
||||
&image->pimage.layout.slices[pSubresource->mipLevel];
|
||||
|
||||
pLayout->offset = slice_layout->offset +
|
||||
(pSubresource->arrayLayer *
|
||||
image->pimage.layout.array_stride);
|
||||
pLayout->offset = slice_layout->offset + (pSubresource->arrayLayer *
|
||||
image->pimage.layout.array_stride);
|
||||
pLayout->size = slice_layout->size;
|
||||
pLayout->rowPitch = slice_layout->row_stride;
|
||||
pLayout->arrayPitch = image->pimage.layout.array_stride;
|
||||
|
|
@ -252,8 +253,7 @@ panvk_GetImageSubresourceLayout(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyImageView(VkDevice _device,
|
||||
VkImageView _view,
|
||||
panvk_DestroyImageView(VkDevice _device, VkImageView _view,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -267,8 +267,7 @@ panvk_DestroyImageView(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyBufferView(VkDevice _device,
|
||||
VkBufferView bufferView,
|
||||
panvk_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -282,13 +281,14 @@ panvk_DestroyBufferView(VkDevice _device,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_GetImageDrmFormatModifierPropertiesEXT(VkDevice device,
|
||||
VkImage _image,
|
||||
VkImageDrmFormatModifierPropertiesEXT *pProperties)
|
||||
panvk_GetImageDrmFormatModifierPropertiesEXT(
|
||||
VkDevice device, VkImage _image,
|
||||
VkImageDrmFormatModifierPropertiesEXT *pProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_image, image, _image);
|
||||
|
||||
assert(pProperties->sType == VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT);
|
||||
assert(pProperties->sType ==
|
||||
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT);
|
||||
|
||||
pProperties->drmFormatModifier = image->pimage.layout.modifier;
|
||||
return VK_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "pan_device.h"
|
||||
#include "panvk_mempool.h"
|
||||
#include "pan_device.h"
|
||||
|
||||
/* Knockoff u_upload_mgr. Uploads wherever we left off, allocating new entries
|
||||
* when needed.
|
||||
|
|
@ -47,7 +47,8 @@ panvk_pool_alloc_backing(struct panvk_pool *pool, size_t bo_sz)
|
|||
|
||||
/* If there's a free BO in our BO pool, let's pick it. */
|
||||
if (pool->bo_pool && bo_sz == pool->base.slab_size &&
|
||||
util_dynarray_num_elements(&pool->bo_pool->free_bos, struct panfrost_bo *)) {
|
||||
util_dynarray_num_elements(&pool->bo_pool->free_bos,
|
||||
struct panfrost_bo *)) {
|
||||
bo = util_dynarray_pop(&pool->bo_pool->free_bos, struct panfrost_bo *);
|
||||
} else {
|
||||
/* We don't know what the BO will be used for, so let's flag it
|
||||
|
|
@ -56,8 +57,7 @@ panvk_pool_alloc_backing(struct panvk_pool *pool, size_t bo_sz)
|
|||
* flags to this function and keep the read/write,
|
||||
* fragment/vertex+tiler pools separate.
|
||||
*/
|
||||
bo = panfrost_bo_create(pool->base.dev, bo_sz,
|
||||
pool->base.create_flags,
|
||||
bo = panfrost_bo_create(pool->base.dev, bo_sz, pool->base.create_flags,
|
||||
pool->base.label);
|
||||
}
|
||||
|
||||
|
|
@ -82,9 +82,8 @@ panvk_pool_alloc_aligned(struct panvk_pool *pool, size_t sz, unsigned alignment)
|
|||
|
||||
/* If we don't fit, allocate a new backing */
|
||||
if (unlikely(bo == NULL || (offset + sz) >= pool->base.slab_size)) {
|
||||
bo = panvk_pool_alloc_backing(pool,
|
||||
ALIGN_POT(MAX2(pool->base.slab_size, sz),
|
||||
4096));
|
||||
bo = panvk_pool_alloc_backing(
|
||||
pool, ALIGN_POT(MAX2(pool->base.slab_size, sz), 4096));
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
|
|
@ -100,10 +99,9 @@ panvk_pool_alloc_aligned(struct panvk_pool *pool, size_t sz, unsigned alignment)
|
|||
PAN_POOL_ALLOCATOR(struct panvk_pool, panvk_pool_alloc_aligned)
|
||||
|
||||
void
|
||||
panvk_pool_init(struct panvk_pool *pool,
|
||||
struct panfrost_device *dev, struct panvk_bo_pool *bo_pool,
|
||||
unsigned create_flags, size_t slab_size, const char *label,
|
||||
bool prealloc)
|
||||
panvk_pool_init(struct panvk_pool *pool, struct panfrost_device *dev,
|
||||
struct panvk_bo_pool *bo_pool, unsigned create_flags,
|
||||
size_t slab_size, const char *label, bool prealloc)
|
||||
{
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
pan_pool_init(&pool->base, dev, create_flags, slab_size, label);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,14 @@ struct panvk_bo_pool {
|
|||
struct util_dynarray free_bos;
|
||||
};
|
||||
|
||||
static inline void panvk_bo_pool_init(struct panvk_bo_pool *bo_pool)
|
||||
static inline void
|
||||
panvk_bo_pool_init(struct panvk_bo_pool *bo_pool)
|
||||
{
|
||||
util_dynarray_init(&bo_pool->free_bos, NULL);
|
||||
}
|
||||
|
||||
static inline void panvk_bo_pool_cleanup(struct panvk_bo_pool *bo_pool)
|
||||
static inline void
|
||||
panvk_bo_pool_cleanup(struct panvk_bo_pool *bo_pool)
|
||||
{
|
||||
util_dynarray_foreach(&bo_pool->free_bos, struct panfrost_bo *, bo)
|
||||
panfrost_bo_unreference(*bo);
|
||||
|
|
@ -72,16 +74,13 @@ to_panvk_pool(struct pan_pool *pool)
|
|||
return container_of(pool, struct panvk_pool, base);
|
||||
}
|
||||
|
||||
void
|
||||
panvk_pool_init(struct panvk_pool *pool, struct panfrost_device *dev,
|
||||
struct panvk_bo_pool *bo_pool, unsigned create_flags,
|
||||
size_t slab_size, const char *label, bool prealloc);
|
||||
void panvk_pool_init(struct panvk_pool *pool, struct panfrost_device *dev,
|
||||
struct panvk_bo_pool *bo_pool, unsigned create_flags,
|
||||
size_t slab_size, const char *label, bool prealloc);
|
||||
|
||||
void
|
||||
panvk_pool_reset(struct panvk_pool *pool);
|
||||
void panvk_pool_reset(struct panvk_pool *pool);
|
||||
|
||||
void
|
||||
panvk_pool_cleanup(struct panvk_pool *pool);
|
||||
void panvk_pool_cleanup(struct panvk_pool *pool);
|
||||
|
||||
static inline unsigned
|
||||
panvk_pool_num_bos(struct panvk_pool *pool)
|
||||
|
|
@ -89,7 +88,6 @@ panvk_pool_num_bos(struct panvk_pool *pool)
|
|||
return util_dynarray_num_elements(&pool->bos, struct panfrost_bo *);
|
||||
}
|
||||
|
||||
void
|
||||
panvk_pool_get_bo_handles(struct panvk_pool *pool, uint32_t *handles);
|
||||
void panvk_pool_get_bo_handles(struct panvk_pool *pool, uint32_t *handles);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,12 +56,13 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
|
||||
pass->attachment_count = pCreateInfo->attachmentCount;
|
||||
pass->subpass_count = pCreateInfo->subpassCount;
|
||||
pass->attachments = (void *) pass + attachments_offset;
|
||||
pass->attachments = (void *)pass + attachments_offset;
|
||||
|
||||
vk_foreach_struct_const(ext, pCreateInfo->pNext) {
|
||||
vk_foreach_struct_const(ext, pCreateInfo->pNext)
|
||||
{
|
||||
switch (ext->sType) {
|
||||
case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
|
||||
multiview_info = (VkRenderPassMultiviewCreateInfo *) ext;
|
||||
multiview_info = (VkRenderPassMultiviewCreateInfo *)ext;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -71,7 +72,8 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
|
||||
struct panvk_render_pass_attachment *att = &pass->attachments[i];
|
||||
|
||||
att->format = vk_format_to_pipe_format(pCreateInfo->pAttachments[i].format);
|
||||
att->format =
|
||||
vk_format_to_pipe_format(pCreateInfo->pAttachments[i].format);
|
||||
att->samples = pCreateInfo->pAttachments[i].samples;
|
||||
att->load_op = pCreateInfo->pAttachments[i].loadOp;
|
||||
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
|
||||
|
|
@ -94,11 +96,10 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
}
|
||||
|
||||
if (subpass_attachment_count) {
|
||||
pass->subpass_attachments =
|
||||
vk_alloc2(&device->vk.alloc, pAllocator,
|
||||
subpass_attachment_count *
|
||||
sizeof(struct panvk_subpass_attachment),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
pass->subpass_attachments = vk_alloc2(
|
||||
&device->vk.alloc, pAllocator,
|
||||
subpass_attachment_count * sizeof(struct panvk_subpass_attachment), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (pass->subpass_attachments == NULL) {
|
||||
vk_object_free(&device->vk, pAllocator, pass);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
|
@ -120,7 +121,7 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
p += desc->inputAttachmentCount;
|
||||
|
||||
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
||||
subpass->input_attachments[j] = (struct panvk_subpass_attachment) {
|
||||
subpass->input_attachments[j] = (struct panvk_subpass_attachment){
|
||||
.idx = desc->pInputAttachments[j].attachment,
|
||||
.layout = desc->pInputAttachments[j].layout,
|
||||
};
|
||||
|
|
@ -137,7 +138,7 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||
uint32_t idx = desc->pColorAttachments[j].attachment;
|
||||
|
||||
subpass->color_attachments[j] = (struct panvk_subpass_attachment) {
|
||||
subpass->color_attachments[j] = (struct panvk_subpass_attachment){
|
||||
.idx = idx,
|
||||
.layout = desc->pColorAttachments[j].layout,
|
||||
};
|
||||
|
|
@ -146,9 +147,11 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
pass->attachments[idx].view_mask |= subpass->view_mask;
|
||||
if (pass->attachments[idx].first_used_in_subpass == ~0) {
|
||||
pass->attachments[idx].first_used_in_subpass = i;
|
||||
if (pass->attachments[idx].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
if (pass->attachments[idx].load_op ==
|
||||
VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
subpass->color_attachments[j].clear = true;
|
||||
else if (pass->attachments[idx].load_op == VK_ATTACHMENT_LOAD_OP_LOAD)
|
||||
else if (pass->attachments[idx].load_op ==
|
||||
VK_ATTACHMENT_LOAD_OP_LOAD)
|
||||
subpass->color_attachments[j].preload = true;
|
||||
} else {
|
||||
subpass->color_attachments[j].preload = true;
|
||||
|
|
@ -164,7 +167,7 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||
uint32_t idx = desc->pResolveAttachments[j].attachment;
|
||||
|
||||
subpass->resolve_attachments[j] = (struct panvk_subpass_attachment) {
|
||||
subpass->resolve_attachments[j] = (struct panvk_subpass_attachment){
|
||||
.idx = idx,
|
||||
.layout = desc->pResolveAttachments[j].layout,
|
||||
};
|
||||
|
|
@ -174,9 +177,9 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned idx = desc->pDepthStencilAttachment ?
|
||||
desc->pDepthStencilAttachment->attachment :
|
||||
VK_ATTACHMENT_UNUSED;
|
||||
unsigned idx = desc->pDepthStencilAttachment
|
||||
? desc->pDepthStencilAttachment->attachment
|
||||
: VK_ATTACHMENT_UNUSED;
|
||||
subpass->zs_attachment.idx = idx;
|
||||
if (idx != VK_ATTACHMENT_UNUSED) {
|
||||
subpass->zs_attachment.layout = desc->pDepthStencilAttachment->layout;
|
||||
|
|
@ -186,7 +189,8 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
pass->attachments[idx].first_used_in_subpass = i;
|
||||
if (pass->attachments[idx].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
subpass->zs_attachment.clear = true;
|
||||
else if (pass->attachments[idx].load_op == VK_ATTACHMENT_LOAD_OP_LOAD)
|
||||
else if (pass->attachments[idx].load_op ==
|
||||
VK_ATTACHMENT_LOAD_OP_LOAD)
|
||||
subpass->zs_attachment.preload = true;
|
||||
} else {
|
||||
subpass->zs_attachment.preload = true;
|
||||
|
|
@ -199,8 +203,7 @@ panvk_CreateRenderPass2(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyRenderPass(VkDevice _device,
|
||||
VkRenderPass _pass,
|
||||
panvk_DestroyRenderPass(VkDevice _device, VkRenderPass _pass,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -214,10 +217,9 @@ panvk_DestroyRenderPass(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_GetRenderAreaGranularity(VkDevice _device,
|
||||
VkRenderPass renderPass,
|
||||
panvk_GetRenderAreaGranularity(VkDevice _device, VkRenderPass renderPass,
|
||||
VkExtent2D *pGranularity)
|
||||
{
|
||||
/* TODO: Return the actual tile size for the render pass? */
|
||||
*pGranularity = (VkExtent2D) { 1, 1 };
|
||||
*pGranularity = (VkExtent2D){1, 1};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,16 +34,14 @@
|
|||
#include "nir/nir.h"
|
||||
#include "nir/nir_builder.h"
|
||||
#include "spirv/nir_spirv.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
|
||||
void
|
||||
panvk_DestroyPipeline(VkDevice _device,
|
||||
VkPipeline _pipeline,
|
||||
panvk_DestroyPipeline(VkDevice _device, VkPipeline _pipeline,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@
|
|||
#include "pan_blend.h"
|
||||
#include "pan_cs.h"
|
||||
#include "pan_device.h"
|
||||
#include "panvk_mempool.h"
|
||||
#include "pan_texture.h"
|
||||
#include "pan_scoreboard.h"
|
||||
#include "vk_extensions.h"
|
||||
#include "pan_texture.h"
|
||||
#include "panvk_mempool.h"
|
||||
#include "panvk_varyings.h"
|
||||
#include "vk_extensions.h"
|
||||
|
||||
/* Pre-declarations needed for WSI entrypoints */
|
||||
struct wl_surface;
|
||||
|
|
@ -88,43 +88,41 @@ typedef uint32_t xcb_window_t;
|
|||
|
||||
#include "panvk_entrypoints.h"
|
||||
|
||||
#define MAX_BIND_POINTS 2 /* compute + graphics */
|
||||
#define MAX_VBS 16
|
||||
#define MAX_VERTEX_ATTRIBS 16
|
||||
#define MAX_RTS 8
|
||||
#define MAX_VSC_PIPES 32
|
||||
#define MAX_VIEWPORTS 1
|
||||
#define MAX_SCISSORS 16
|
||||
#define MAX_DISCARD_RECTANGLES 4
|
||||
#define MAX_PUSH_CONSTANTS_SIZE 128
|
||||
#define MAX_PUSH_DESCRIPTORS 32
|
||||
#define MAX_BIND_POINTS 2 /* compute + graphics */
|
||||
#define MAX_VBS 16
|
||||
#define MAX_VERTEX_ATTRIBS 16
|
||||
#define MAX_RTS 8
|
||||
#define MAX_VSC_PIPES 32
|
||||
#define MAX_VIEWPORTS 1
|
||||
#define MAX_SCISSORS 16
|
||||
#define MAX_DISCARD_RECTANGLES 4
|
||||
#define MAX_PUSH_CONSTANTS_SIZE 128
|
||||
#define MAX_PUSH_DESCRIPTORS 32
|
||||
#define MAX_DYNAMIC_UNIFORM_BUFFERS 16
|
||||
#define MAX_DYNAMIC_STORAGE_BUFFERS 8
|
||||
#define MAX_DYNAMIC_BUFFERS \
|
||||
#define MAX_DYNAMIC_BUFFERS \
|
||||
(MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
|
||||
#define MAX_SAMPLES_LOG2 4
|
||||
#define NUM_META_FS_KEYS 13
|
||||
#define MAX_VIEWS 8
|
||||
#define MAX_VIEWS 8
|
||||
|
||||
#define NUM_DEPTH_CLEAR_PIPELINES 3
|
||||
|
||||
#define PANVK_SYSVAL_UBO_INDEX 0
|
||||
#define PANVK_SYSVAL_UBO_INDEX 0
|
||||
#define PANVK_PUSH_CONST_UBO_INDEX 1
|
||||
#define PANVK_NUM_BUILTIN_UBOS 2
|
||||
#define PANVK_NUM_BUILTIN_UBOS 2
|
||||
|
||||
#define panvk_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||
|
||||
void
|
||||
panvk_logi(const char *format, ...) panvk_printflike(1, 2);
|
||||
void
|
||||
panvk_logi_v(const char *format, va_list va);
|
||||
void panvk_logi(const char *format, ...) panvk_printflike(1, 2);
|
||||
void panvk_logi_v(const char *format, va_list va);
|
||||
|
||||
#define panvk_stub() assert(!"stub")
|
||||
|
||||
#define PANVK_META_COPY_BUF2IMG_NUM_FORMATS 12
|
||||
#define PANVK_META_COPY_IMG2BUF_NUM_FORMATS 12
|
||||
#define PANVK_META_COPY_IMG2IMG_NUM_FORMATS 14
|
||||
#define PANVK_META_COPY_NUM_TEX_TYPES 5
|
||||
#define PANVK_META_COPY_BUF2IMG_NUM_FORMATS 12
|
||||
#define PANVK_META_COPY_IMG2BUF_NUM_FORMATS 12
|
||||
#define PANVK_META_COPY_IMG2IMG_NUM_FORMATS 14
|
||||
#define PANVK_META_COPY_NUM_TEX_TYPES 5
|
||||
#define PANVK_META_COPY_BUF2BUF_NUM_BLKSIZES 5
|
||||
|
||||
static inline unsigned
|
||||
|
|
@ -161,10 +159,12 @@ struct panvk_meta {
|
|||
} buf2img[PANVK_META_COPY_BUF2IMG_NUM_FORMATS];
|
||||
struct {
|
||||
mali_ptr rsd;
|
||||
} img2buf[PANVK_META_COPY_NUM_TEX_TYPES][PANVK_META_COPY_IMG2BUF_NUM_FORMATS];
|
||||
} img2buf[PANVK_META_COPY_NUM_TEX_TYPES]
|
||||
[PANVK_META_COPY_IMG2BUF_NUM_FORMATS];
|
||||
struct {
|
||||
mali_ptr rsd;
|
||||
} img2img[2][PANVK_META_COPY_NUM_TEX_TYPES][PANVK_META_COPY_IMG2IMG_NUM_FORMATS];
|
||||
} img2img[2][PANVK_META_COPY_NUM_TEX_TYPES]
|
||||
[PANVK_META_COPY_IMG2IMG_NUM_FORMATS];
|
||||
struct {
|
||||
mali_ptr rsd;
|
||||
} buf2buf[PANVK_META_COPY_BUF2BUF_NUM_BLKSIZES];
|
||||
|
|
@ -215,18 +215,14 @@ struct panvk_instance {
|
|||
enum panvk_debug_flags debug_flags;
|
||||
};
|
||||
|
||||
VkResult
|
||||
panvk_wsi_init(struct panvk_physical_device *physical_device);
|
||||
void
|
||||
panvk_wsi_finish(struct panvk_physical_device *physical_device);
|
||||
VkResult panvk_wsi_init(struct panvk_physical_device *physical_device);
|
||||
void panvk_wsi_finish(struct panvk_physical_device *physical_device);
|
||||
|
||||
bool
|
||||
panvk_instance_extension_supported(const char *name);
|
||||
uint32_t
|
||||
panvk_physical_device_api_version(struct panvk_physical_device *dev);
|
||||
bool panvk_instance_extension_supported(const char *name);
|
||||
uint32_t panvk_physical_device_api_version(struct panvk_physical_device *dev);
|
||||
bool
|
||||
panvk_physical_device_extension_supported(struct panvk_physical_device *dev,
|
||||
const char *name);
|
||||
const char *name);
|
||||
|
||||
struct panvk_pipeline_cache {
|
||||
struct vk_object_base base;
|
||||
|
|
@ -255,10 +251,10 @@ struct panvk_device {
|
|||
int _lost;
|
||||
};
|
||||
|
||||
VkResult _panvk_device_set_lost(struct panvk_device *device,
|
||||
const char *file, int line,
|
||||
const char *msg, ...) PRINTFLIKE(4, 5);
|
||||
#define panvk_device_set_lost(dev, ...) \
|
||||
VkResult _panvk_device_set_lost(struct panvk_device *device, const char *file,
|
||||
int line, const char *msg, ...)
|
||||
PRINTFLIKE(4, 5);
|
||||
#define panvk_device_set_lost(dev, ...) \
|
||||
_panvk_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
static inline bool
|
||||
|
|
@ -267,7 +263,7 @@ panvk_device_is_lost(struct panvk_device *device)
|
|||
return unlikely(p_atomic_read(&device->_lost));
|
||||
}
|
||||
|
||||
#define TILER_DESC_WORDS 56
|
||||
#define TILER_DESC_WORDS 56
|
||||
|
||||
struct panvk_batch {
|
||||
struct list_head node;
|
||||
|
|
@ -430,8 +426,7 @@ panvk_pipeline_layout_ubo_start(const struct panvk_pipeline_layout *layout,
|
|||
const struct panvk_descriptor_set_layout *set_layout =
|
||||
vk_to_panvk_descriptor_set_layout(layout->vk.set_layouts[set]);
|
||||
|
||||
unsigned offset = PANVK_NUM_BUILTIN_UBOS +
|
||||
layout->sets[set].ubo_offset +
|
||||
unsigned offset = PANVK_NUM_BUILTIN_UBOS + layout->sets[set].ubo_offset +
|
||||
layout->sets[set].dyn_ubo_offset;
|
||||
|
||||
if (is_dynamic)
|
||||
|
|
@ -452,11 +447,11 @@ panvk_pipeline_layout_ubo_index(const struct panvk_pipeline_layout *layout,
|
|||
|
||||
const bool is_dynamic =
|
||||
binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
||||
const uint32_t ubo_idx = is_dynamic ? binding_layout->dyn_ubo_idx :
|
||||
binding_layout->ubo_idx;
|
||||
const uint32_t ubo_idx =
|
||||
is_dynamic ? binding_layout->dyn_ubo_idx : binding_layout->ubo_idx;
|
||||
|
||||
return panvk_pipeline_layout_ubo_start(layout, set, is_dynamic) +
|
||||
ubo_idx + array_index;
|
||||
return panvk_pipeline_layout_ubo_start(layout, set, is_dynamic) + ubo_idx +
|
||||
array_index;
|
||||
}
|
||||
|
||||
struct panvk_desc_pool_counters {
|
||||
|
|
@ -498,8 +493,8 @@ panvk_buffer_gpu_ptr(const struct panvk_buffer *buffer, uint64_t offset)
|
|||
}
|
||||
|
||||
static inline uint64_t
|
||||
panvk_buffer_range(const struct panvk_buffer *buffer,
|
||||
uint64_t offset, uint64_t range)
|
||||
panvk_buffer_range(const struct panvk_buffer *buffer, uint64_t offset,
|
||||
uint64_t range)
|
||||
{
|
||||
if (buffer->bo == NULL)
|
||||
return 0;
|
||||
|
|
@ -754,31 +749,25 @@ struct panvk_cmd_buffer {
|
|||
struct panvk_cmd_bind_point_state bind_points[MAX_BIND_POINTS];
|
||||
};
|
||||
|
||||
#define panvk_cmd_get_bind_point_state(cmdbuf, bindpoint) \
|
||||
&(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint]
|
||||
#define panvk_cmd_get_bind_point_state(cmdbuf, bindpoint) \
|
||||
&(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_##bindpoint]
|
||||
|
||||
#define panvk_cmd_get_pipeline(cmdbuf, bindpoint) \
|
||||
(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint].pipeline
|
||||
#define panvk_cmd_get_pipeline(cmdbuf, bindpoint) \
|
||||
(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_##bindpoint].pipeline
|
||||
|
||||
#define panvk_cmd_get_desc_state(cmdbuf, bindpoint) \
|
||||
&(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint].desc_state
|
||||
#define panvk_cmd_get_desc_state(cmdbuf, bindpoint) \
|
||||
&(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_##bindpoint].desc_state
|
||||
|
||||
struct panvk_batch *
|
||||
panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf);
|
||||
struct panvk_batch *panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void
|
||||
panvk_cmd_fb_info_set_subpass(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_cmd_fb_info_set_subpass(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void
|
||||
panvk_cmd_fb_info_init(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_cmd_fb_info_init(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void
|
||||
panvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void
|
||||
panvk_pack_color(struct panvk_clear_value *out,
|
||||
const VkClearColorValue *in,
|
||||
enum pipe_format format);
|
||||
void panvk_pack_color(struct panvk_clear_value *out,
|
||||
const VkClearColorValue *in, enum pipe_format format);
|
||||
|
||||
struct panvk_event {
|
||||
struct vk_object_base base;
|
||||
|
|
@ -794,21 +783,17 @@ struct panvk_shader {
|
|||
};
|
||||
|
||||
struct panvk_shader *
|
||||
panvk_shader_create(struct panvk_device *dev,
|
||||
gl_shader_stage stage,
|
||||
panvk_shader_create(struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
unsigned sysval_ubo,
|
||||
struct pan_blend_state *blend_state,
|
||||
unsigned sysval_ubo, struct pan_blend_state *blend_state,
|
||||
bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
void
|
||||
panvk_shader_destroy(struct panvk_device *dev,
|
||||
struct panvk_shader *shader,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
void panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
#define RSD_WORDS 16
|
||||
#define RSD_WORDS 16
|
||||
#define BLEND_DESC_WORDS 4
|
||||
|
||||
struct panvk_pipeline {
|
||||
|
|
@ -921,13 +906,12 @@ struct panvk_image {
|
|||
struct pan_image pimage;
|
||||
};
|
||||
|
||||
unsigned
|
||||
panvk_image_get_plane_size(const struct panvk_image *image, unsigned plane);
|
||||
unsigned panvk_image_get_plane_size(const struct panvk_image *image,
|
||||
unsigned plane);
|
||||
|
||||
unsigned
|
||||
panvk_image_get_total_size(const struct panvk_image *image);
|
||||
unsigned panvk_image_get_total_size(const struct panvk_image *image);
|
||||
|
||||
#define TEXTURE_DESC_WORDS 8
|
||||
#define TEXTURE_DESC_WORDS 8
|
||||
#define ATTRIB_BUF_DESC_WORDS 4
|
||||
|
||||
struct panvk_image_view {
|
||||
|
|
@ -1028,40 +1012,63 @@ struct panvk_render_pass {
|
|||
struct panvk_subpass subpasses[0];
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, vk.base, VkCommandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, vk.base, VkCommandBuffer,
|
||||
VK_OBJECT_TYPE_COMMAND_BUFFER)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_physical_device, vk.base, VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_instance, vk.base, VkInstance,
|
||||
VK_OBJECT_TYPE_INSTANCE)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_physical_device, vk.base, VkPhysicalDevice,
|
||||
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, vk.base, VkCommandPool, VK_OBJECT_TYPE_COMMAND_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer_view, base, VkBufferView, VK_OBJECT_TYPE_BUFFER_VIEW)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_pool, base, VkDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set, base, VkDescriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, vk.base, VkCommandPool,
|
||||
VK_OBJECT_TYPE_COMMAND_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer, vk.base, VkBuffer,
|
||||
VK_OBJECT_TYPE_BUFFER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer_view, base, VkBufferView,
|
||||
VK_OBJECT_TYPE_BUFFER_VIEW)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_pool, base, VkDescriptorPool,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set, base, VkDescriptorSet,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set_layout, vk.base,
|
||||
VkDescriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_device_memory, base, VkDeviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY)
|
||||
VkDescriptorSetLayout,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_device_memory, base, VkDeviceMemory,
|
||||
VK_OBJECT_TYPE_DEVICE_MEMORY)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_framebuffer, base, VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, vk.base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW);
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_cache, base, VkPipelineCache, VK_OBJECT_TYPE_PIPELINE_CACHE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline, VK_OBJECT_TYPE_PIPELINE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_layout, vk.base, VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_render_pass, base, VkRenderPass, VK_OBJECT_TYPE_RENDER_PASS)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_sampler, base, VkSampler, VK_OBJECT_TYPE_SAMPLER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_framebuffer, base, VkFramebuffer,
|
||||
VK_OBJECT_TYPE_FRAMEBUFFER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, vk.base, VkImage,
|
||||
VK_OBJECT_TYPE_IMAGE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, vk.base, VkImageView,
|
||||
VK_OBJECT_TYPE_IMAGE_VIEW);
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_cache, base, VkPipelineCache,
|
||||
VK_OBJECT_TYPE_PIPELINE_CACHE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline,
|
||||
VK_OBJECT_TYPE_PIPELINE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_layout, vk.base, VkPipelineLayout,
|
||||
VK_OBJECT_TYPE_PIPELINE_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_render_pass, base, VkRenderPass,
|
||||
VK_OBJECT_TYPE_RENDER_PASS)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_sampler, base, VkSampler,
|
||||
VK_OBJECT_TYPE_SAMPLER)
|
||||
|
||||
#define panvk_arch_name(name, version) panvk_## version ## _ ## name
|
||||
#define panvk_arch_name(name, version) panvk_##version##_##name
|
||||
|
||||
#define panvk_arch_dispatch(arch, name, ...) \
|
||||
do { \
|
||||
switch (arch) { \
|
||||
case 6: panvk_arch_name(name, v6)(__VA_ARGS__); break; \
|
||||
case 7: panvk_arch_name(name, v7)(__VA_ARGS__); break; \
|
||||
default: unreachable("Invalid arch"); \
|
||||
} \
|
||||
} while (0)
|
||||
#define panvk_arch_dispatch(arch, name, ...) \
|
||||
do { \
|
||||
switch (arch) { \
|
||||
case 6: \
|
||||
panvk_arch_name(name, v6)(__VA_ARGS__); \
|
||||
break; \
|
||||
case 7: \
|
||||
panvk_arch_name(name, v7)(__VA_ARGS__); \
|
||||
break; \
|
||||
default: \
|
||||
unreachable("Invalid arch"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef PAN_ARCH
|
||||
#if PAN_ARCH == 6
|
||||
|
|
@ -1074,7 +1081,7 @@ do { \
|
|||
#include "panvk_vX_device.h"
|
||||
#include "panvk_vX_meta.h"
|
||||
#else
|
||||
#define PAN_ARCH 6
|
||||
#define PAN_ARCH 6
|
||||
#define panvk_per_arch(name) panvk_arch_name(name, v6)
|
||||
#include "panvk_vX_cmd_buffer.h"
|
||||
#include "panvk_vX_cs.h"
|
||||
|
|
@ -1082,7 +1089,7 @@ do { \
|
|||
#include "panvk_vX_meta.h"
|
||||
#undef PAN_ARCH
|
||||
#undef panvk_per_arch
|
||||
#define PAN_ARCH 7
|
||||
#define PAN_ARCH 7
|
||||
#define panvk_per_arch(name) panvk_arch_name(name, v7)
|
||||
#include "panvk_vX_cmd_buffer.h"
|
||||
#include "panvk_vX_cs.h"
|
||||
|
|
@ -1093,27 +1100,21 @@ do { \
|
|||
#endif
|
||||
|
||||
#ifdef PAN_ARCH
|
||||
bool
|
||||
panvk_per_arch(blend_needs_lowering)(const struct panfrost_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt);
|
||||
bool panvk_per_arch(blend_needs_lowering)(const struct panfrost_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt);
|
||||
|
||||
struct panvk_shader *
|
||||
panvk_per_arch(shader_create)(struct panvk_device *dev,
|
||||
gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
unsigned sysval_ubo,
|
||||
struct pan_blend_state *blend_state,
|
||||
bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
struct panvk_shader *panvk_per_arch(shader_create)(
|
||||
struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout, unsigned sysval_ubo,
|
||||
struct pan_blend_state *blend_state, bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
struct nir_shader;
|
||||
|
||||
bool
|
||||
panvk_per_arch(nir_lower_descriptors)(struct nir_shader *nir,
|
||||
struct panvk_device *dev,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
bool *has_img_access_out);
|
||||
bool panvk_per_arch(nir_lower_descriptors)(
|
||||
struct nir_shader *nir, struct panvk_device *dev,
|
||||
const struct panvk_pipeline_layout *layout, bool *has_img_access_out);
|
||||
#endif
|
||||
|
||||
#endif /* PANVK_PRIVATE_H */
|
||||
|
|
|
|||
|
|
@ -34,21 +34,16 @@ panvk_CreateQueryPool(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_DestroyQueryPool(VkDevice _device,
|
||||
VkQueryPool _pool,
|
||||
panvk_DestroyQueryPool(VkDevice _device, VkQueryPool _pool,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
VkResult
|
||||
panvk_GetQueryPoolResults(VkDevice _device,
|
||||
VkQueryPool queryPool,
|
||||
uint32_t firstQuery,
|
||||
uint32_t queryCount,
|
||||
size_t dataSize,
|
||||
void *pData,
|
||||
VkDeviceSize stride,
|
||||
panvk_GetQueryPoolResults(VkDevice _device, VkQueryPool queryPool,
|
||||
uint32_t firstQuery, uint32_t queryCount,
|
||||
size_t dataSize, void *pData, VkDeviceSize stride,
|
||||
VkQueryResultFlags flags)
|
||||
{
|
||||
panvk_stub();
|
||||
|
|
@ -57,38 +52,30 @@ panvk_GetQueryPoolResults(VkDevice _device,
|
|||
|
||||
void
|
||||
panvk_CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer,
|
||||
VkQueryPool queryPool,
|
||||
uint32_t firstQuery,
|
||||
uint32_t queryCount,
|
||||
VkBuffer dstBuffer,
|
||||
VkDeviceSize dstOffset,
|
||||
VkDeviceSize stride,
|
||||
VkQueryPool queryPool, uint32_t firstQuery,
|
||||
uint32_t queryCount, VkBuffer dstBuffer,
|
||||
VkDeviceSize dstOffset, VkDeviceSize stride,
|
||||
VkQueryResultFlags flags)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdResetQueryPool(VkCommandBuffer commandBuffer,
|
||||
VkQueryPool queryPool,
|
||||
uint32_t firstQuery,
|
||||
uint32_t queryCount)
|
||||
panvk_CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
|
||||
uint32_t firstQuery, uint32_t queryCount)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdBeginQuery(VkCommandBuffer commandBuffer,
|
||||
VkQueryPool queryPool,
|
||||
uint32_t query,
|
||||
VkQueryControlFlags flags)
|
||||
panvk_CmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
|
||||
uint32_t query, VkQueryControlFlags flags)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
||||
void
|
||||
panvk_CmdEndQuery(VkCommandBuffer commandBuffer,
|
||||
VkQueryPool queryPool,
|
||||
panvk_CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
|
||||
uint32_t query)
|
||||
{
|
||||
panvk_stub();
|
||||
|
|
@ -96,8 +83,7 @@ panvk_CmdEndQuery(VkCommandBuffer commandBuffer,
|
|||
|
||||
void
|
||||
panvk_CmdWriteTimestamp2(VkCommandBuffer commandBuffer,
|
||||
VkPipelineStageFlags2 stage,
|
||||
VkQueryPool queryPool,
|
||||
VkPipelineStageFlags2 stage, VkQueryPool queryPool,
|
||||
uint32_t query)
|
||||
{
|
||||
panvk_stub();
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@
|
|||
#include "vk_util.h"
|
||||
|
||||
void
|
||||
panvk_shader_destroy(struct panvk_device *dev,
|
||||
struct panvk_shader *shader,
|
||||
panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader,
|
||||
const VkAllocationCallbacks *alloc)
|
||||
{
|
||||
util_dynarray_fini(&shader->binary);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@
|
|||
#include "vk_enum_to_str.h"
|
||||
|
||||
/** Log an error message. */
|
||||
void panvk_printflike(1, 2)
|
||||
panvk_logi(const char *format, ...)
|
||||
void panvk_printflike(1, 2) panvk_logi(const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,9 @@
|
|||
|
||||
static uint32_t
|
||||
panvk_debug_adjust_bo_flags(const struct panvk_device *device,
|
||||
uint32_t bo_flags)
|
||||
uint32_t bo_flags)
|
||||
{
|
||||
uint32_t debug_flags =
|
||||
device->physical_device->instance->debug_flags;
|
||||
uint32_t debug_flags = device->physical_device->instance->debug_flags;
|
||||
|
||||
if (debug_flags & PANVK_DEBUG_DUMP)
|
||||
bo_flags &= ~PAN_BO_INVISIBLE;
|
||||
|
|
@ -60,8 +59,8 @@ panvk_cmd_prepare_fragment_job(struct panvk_cmd_buffer *cmdbuf)
|
|||
struct panfrost_ptr job_ptr =
|
||||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, FRAGMENT_JOB);
|
||||
|
||||
GENX(pan_emit_fragment_job)(fbinfo, batch->fb.desc.gpu, job_ptr.cpu),
|
||||
batch->fragment_job = job_ptr.gpu;
|
||||
GENX(pan_emit_fragment_job)
|
||||
(fbinfo, batch->fb.desc.gpu, job_ptr.cpu), batch->fragment_job = job_ptr.gpu;
|
||||
util_dynarray_append(&batch->jobs, void *, job_ptr.cpu);
|
||||
}
|
||||
|
||||
|
|
@ -82,19 +81,19 @@ panvk_per_arch(cmd_close_batch)(struct panvk_cmd_buffer *cmdbuf)
|
|||
clear |= fbinfo->rts[i].clear;
|
||||
|
||||
if (!clear && !batch->scoreboard.first_job) {
|
||||
if (util_dynarray_num_elements(&batch->event_ops, struct panvk_event_op) == 0) {
|
||||
if (util_dynarray_num_elements(&batch->event_ops,
|
||||
struct panvk_event_op) == 0) {
|
||||
/* Content-less batch, let's drop it */
|
||||
vk_free(&cmdbuf->vk.pool->alloc, batch);
|
||||
} else {
|
||||
/* Batch has no jobs but is needed for synchronization, let's add a
|
||||
* NULL job so the SUBMIT ioctl doesn't choke on it.
|
||||
*/
|
||||
struct panfrost_ptr ptr = pan_pool_alloc_desc(&cmdbuf->desc_pool.base,
|
||||
JOB_HEADER);
|
||||
struct panfrost_ptr ptr =
|
||||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, JOB_HEADER);
|
||||
util_dynarray_append(&batch->jobs, void *, ptr.cpu);
|
||||
panfrost_add_job(&cmdbuf->desc_pool.base, &batch->scoreboard,
|
||||
MALI_JOB_TYPE_NULL, false, false, 0, 0,
|
||||
&ptr, false);
|
||||
MALI_JOB_TYPE_NULL, false, false, 0, 0, &ptr, false);
|
||||
list_addtail(&batch->node, &cmdbuf->batches);
|
||||
}
|
||||
cmdbuf->state.batch = NULL;
|
||||
|
|
@ -107,18 +106,16 @@ panvk_per_arch(cmd_close_batch)(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
if (batch->scoreboard.first_tiler) {
|
||||
struct panfrost_ptr preload_jobs[2];
|
||||
unsigned num_preload_jobs =
|
||||
GENX(pan_preload_fb)(&cmdbuf->desc_pool.base, &batch->scoreboard,
|
||||
&cmdbuf->state.fb.info, batch->tls.gpu,
|
||||
batch->tiler.descs.gpu, preload_jobs);
|
||||
unsigned num_preload_jobs = GENX(pan_preload_fb)(
|
||||
&cmdbuf->desc_pool.base, &batch->scoreboard, &cmdbuf->state.fb.info,
|
||||
batch->tls.gpu, batch->tiler.descs.gpu, preload_jobs);
|
||||
for (unsigned i = 0; i < num_preload_jobs; i++)
|
||||
util_dynarray_append(&batch->jobs, void *, preload_jobs[i].cpu);
|
||||
}
|
||||
|
||||
if (batch->tlsinfo.tls.size) {
|
||||
unsigned size = panfrost_get_total_stack_size(batch->tlsinfo.tls.size,
|
||||
pdev->thread_tls_alloc,
|
||||
pdev->core_id_range);
|
||||
unsigned size = panfrost_get_total_stack_size(
|
||||
batch->tlsinfo.tls.size, pdev->thread_tls_alloc, pdev->core_id_range);
|
||||
batch->tlsinfo.tls.ptr =
|
||||
pan_pool_alloc_aligned(&cmdbuf->tls_pool.base, size, 4096).gpu;
|
||||
}
|
||||
|
|
@ -126,7 +123,9 @@ panvk_per_arch(cmd_close_batch)(struct panvk_cmd_buffer *cmdbuf)
|
|||
if (batch->tlsinfo.wls.size) {
|
||||
assert(batch->wls_total_size);
|
||||
batch->tlsinfo.wls.ptr =
|
||||
pan_pool_alloc_aligned(&cmdbuf->tls_pool.base, batch->wls_total_size, 4096).gpu;
|
||||
pan_pool_alloc_aligned(&cmdbuf->tls_pool.base, batch->wls_total_size,
|
||||
4096)
|
||||
.gpu;
|
||||
}
|
||||
|
||||
if (batch->tls.cpu)
|
||||
|
|
@ -160,10 +159,8 @@ panvk_per_arch(CmdNextSubpass2)(VkCommandBuffer commandBuffer,
|
|||
void
|
||||
panvk_per_arch(CmdNextSubpass)(VkCommandBuffer cmd, VkSubpassContents contents)
|
||||
{
|
||||
VkSubpassBeginInfo binfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO,
|
||||
.contents = contents
|
||||
};
|
||||
VkSubpassBeginInfo binfo = {.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO,
|
||||
.contents = contents};
|
||||
VkSubpassEndInfo einfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO,
|
||||
};
|
||||
|
|
@ -183,11 +180,10 @@ panvk_per_arch(cmd_alloc_fb_desc)(struct panvk_cmd_buffer *cmdbuf)
|
|||
bool has_zs_ext = fbinfo->zs.view.zs || fbinfo->zs.view.s;
|
||||
|
||||
batch->fb.info = cmdbuf->state.framebuffer;
|
||||
batch->fb.desc =
|
||||
pan_pool_alloc_desc_aggregate(&cmdbuf->desc_pool.base,
|
||||
PAN_DESC(FRAMEBUFFER),
|
||||
PAN_DESC_ARRAY(has_zs_ext ? 1 : 0, ZS_CRC_EXTENSION),
|
||||
PAN_DESC_ARRAY(MAX2(fbinfo->rt_count, 1), RENDER_TARGET));
|
||||
batch->fb.desc = pan_pool_alloc_desc_aggregate(
|
||||
&cmdbuf->desc_pool.base, PAN_DESC(FRAMEBUFFER),
|
||||
PAN_DESC_ARRAY(has_zs_ext ? 1 : 0, ZS_CRC_EXTENSION),
|
||||
PAN_DESC_ARRAY(MAX2(fbinfo->rt_count, 1), RENDER_TARGET));
|
||||
|
||||
memset(&cmdbuf->state.fb.info.bifrost.pre_post.dcds, 0,
|
||||
sizeof(cmdbuf->state.fb.info.bifrost.pre_post.dcds));
|
||||
|
|
@ -200,15 +196,15 @@ panvk_per_arch(cmd_alloc_tls_desc)(struct panvk_cmd_buffer *cmdbuf, bool gfx)
|
|||
|
||||
assert(batch);
|
||||
if (!batch->tls.gpu) {
|
||||
batch->tls =
|
||||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, LOCAL_STORAGE);
|
||||
batch->tls = pan_pool_alloc_desc(&cmdbuf->desc_pool.base, LOCAL_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_cmd_prepare_draw_sysvals(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_cmd_bind_point_state *bind_point_state,
|
||||
struct panvk_draw_info *draw)
|
||||
panvk_cmd_prepare_draw_sysvals(
|
||||
struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_cmd_bind_point_state *bind_point_state,
|
||||
struct panvk_draw_info *draw)
|
||||
{
|
||||
struct panvk_sysvals *sysvals = &bind_point_state->desc_state.sysvals;
|
||||
|
||||
|
|
@ -246,16 +242,16 @@ panvk_cmd_prepare_sysvals(struct panvk_cmd_buffer *cmdbuf,
|
|||
if (desc_state->sysvals_ptr)
|
||||
return;
|
||||
|
||||
struct panfrost_ptr sysvals =
|
||||
pan_pool_alloc_aligned(&cmdbuf->desc_pool.base,
|
||||
sizeof(desc_state->sysvals), 16);
|
||||
struct panfrost_ptr sysvals = pan_pool_alloc_aligned(
|
||||
&cmdbuf->desc_pool.base, sizeof(desc_state->sysvals), 16);
|
||||
memcpy(sysvals.cpu, &desc_state->sysvals, sizeof(desc_state->sysvals));
|
||||
desc_state->sysvals_ptr = sysvals.gpu;
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_cmd_prepare_push_constants(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_cmd_bind_point_state *bind_point_state)
|
||||
panvk_cmd_prepare_push_constants(
|
||||
struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_cmd_bind_point_state *bind_point_state)
|
||||
{
|
||||
struct panvk_descriptor_state *desc_state = &bind_point_state->desc_state;
|
||||
const struct panvk_pipeline *pipeline = bind_point_state->pipeline;
|
||||
|
|
@ -263,10 +259,9 @@ panvk_cmd_prepare_push_constants(struct panvk_cmd_buffer *cmdbuf,
|
|||
if (!pipeline->layout->push_constants.size || desc_state->push_constants)
|
||||
return;
|
||||
|
||||
struct panfrost_ptr push_constants =
|
||||
pan_pool_alloc_aligned(&cmdbuf->desc_pool.base,
|
||||
ALIGN_POT(pipeline->layout->push_constants.size, 16),
|
||||
16);
|
||||
struct panfrost_ptr push_constants = pan_pool_alloc_aligned(
|
||||
&cmdbuf->desc_pool.base,
|
||||
ALIGN_POT(pipeline->layout->push_constants.size, 16), 16);
|
||||
|
||||
memcpy(push_constants.cpu, cmdbuf->push_constants,
|
||||
pipeline->layout->push_constants.size);
|
||||
|
|
@ -286,10 +281,8 @@ panvk_cmd_prepare_ubos(struct panvk_cmd_buffer *cmdbuf,
|
|||
panvk_cmd_prepare_sysvals(cmdbuf, bind_point_state);
|
||||
panvk_cmd_prepare_push_constants(cmdbuf, bind_point_state);
|
||||
|
||||
struct panfrost_ptr ubos =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
pipeline->num_ubos,
|
||||
UNIFORM_BUFFER);
|
||||
struct panfrost_ptr ubos = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, pipeline->num_ubos, UNIFORM_BUFFER);
|
||||
|
||||
panvk_per_arch(emit_ubos)(pipeline, desc_state, ubos.cpu);
|
||||
|
||||
|
|
@ -307,23 +300,20 @@ panvk_cmd_prepare_textures(struct panvk_cmd_buffer *cmdbuf,
|
|||
if (!num_textures || desc_state->textures)
|
||||
return;
|
||||
|
||||
struct panfrost_ptr textures =
|
||||
pan_pool_alloc_aligned(&cmdbuf->desc_pool.base,
|
||||
num_textures * pan_size(TEXTURE),
|
||||
pan_size(TEXTURE));
|
||||
struct panfrost_ptr textures = pan_pool_alloc_aligned(
|
||||
&cmdbuf->desc_pool.base, num_textures * pan_size(TEXTURE),
|
||||
pan_size(TEXTURE));
|
||||
|
||||
void *texture = textures.cpu;
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(desc_state->sets); i++) {
|
||||
if (!desc_state->sets[i]) continue;
|
||||
if (!desc_state->sets[i])
|
||||
continue;
|
||||
|
||||
memcpy(texture,
|
||||
desc_state->sets[i]->textures,
|
||||
desc_state->sets[i]->layout->num_textures *
|
||||
pan_size(TEXTURE));
|
||||
memcpy(texture, desc_state->sets[i]->textures,
|
||||
desc_state->sets[i]->layout->num_textures * pan_size(TEXTURE));
|
||||
|
||||
texture += desc_state->sets[i]->layout->num_textures *
|
||||
pan_size(TEXTURE);
|
||||
texture += desc_state->sets[i]->layout->num_textures * pan_size(TEXTURE);
|
||||
}
|
||||
|
||||
desc_state->textures = textures.gpu;
|
||||
|
|
@ -341,9 +331,7 @@ panvk_cmd_prepare_samplers(struct panvk_cmd_buffer *cmdbuf,
|
|||
return;
|
||||
|
||||
struct panfrost_ptr samplers =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
num_samplers,
|
||||
SAMPLER);
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base, num_samplers, SAMPLER);
|
||||
|
||||
void *sampler = samplers.cpu;
|
||||
|
||||
|
|
@ -358,15 +346,13 @@ panvk_cmd_prepare_samplers(struct panvk_cmd_buffer *cmdbuf,
|
|||
sampler += pan_size(SAMPLER);
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(desc_state->sets); i++) {
|
||||
if (!desc_state->sets[i]) continue;
|
||||
if (!desc_state->sets[i])
|
||||
continue;
|
||||
|
||||
memcpy(sampler,
|
||||
desc_state->sets[i]->samplers,
|
||||
desc_state->sets[i]->layout->num_samplers *
|
||||
pan_size(SAMPLER));
|
||||
memcpy(sampler, desc_state->sets[i]->samplers,
|
||||
desc_state->sets[i]->layout->num_samplers * pan_size(SAMPLER));
|
||||
|
||||
sampler += desc_state->sets[i]->layout->num_samplers *
|
||||
pan_size(SAMPLER);
|
||||
sampler += desc_state->sets[i]->layout->num_samplers * pan_size(SAMPLER);
|
||||
}
|
||||
|
||||
desc_state->samplers = samplers.gpu;
|
||||
|
|
@ -385,11 +371,9 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
if (!cmdbuf->state.fs_rsd) {
|
||||
struct panfrost_ptr rsd =
|
||||
pan_pool_alloc_desc_aggregate(&cmdbuf->desc_pool.base,
|
||||
PAN_DESC(RENDERER_STATE),
|
||||
PAN_DESC_ARRAY(pipeline->blend.state.rt_count,
|
||||
BLEND));
|
||||
struct panfrost_ptr rsd = pan_pool_alloc_desc_aggregate(
|
||||
&cmdbuf->desc_pool.base, PAN_DESC(RENDERER_STATE),
|
||||
PAN_DESC_ARRAY(pipeline->blend.state.rt_count, BLEND));
|
||||
|
||||
struct mali_renderer_state_packed rsd_dyn;
|
||||
struct mali_renderer_state_packed *rsd_templ =
|
||||
|
|
@ -408,7 +392,8 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct mali_blend_packed *bd_templ =
|
||||
(struct mali_blend_packed *)&pipeline->blend.bd_template[i];
|
||||
|
||||
STATIC_ASSERT(sizeof(pipeline->blend.bd_template[0]) >= sizeof(*bd_templ));
|
||||
STATIC_ASSERT(sizeof(pipeline->blend.bd_template[0]) >=
|
||||
sizeof(*bd_templ));
|
||||
panvk_per_arch(emit_blend_constant)(cmdbuf->device, pipeline, i,
|
||||
cmdbuf->state.blend.constants,
|
||||
&bd_dyn);
|
||||
|
|
@ -433,10 +418,8 @@ panvk_per_arch(cmd_get_tiler_context)(struct panvk_cmd_buffer *cmdbuf,
|
|||
if (batch->tiler.descs.cpu)
|
||||
return;
|
||||
|
||||
batch->tiler.descs =
|
||||
pan_pool_alloc_desc_aggregate(&cmdbuf->desc_pool.base,
|
||||
PAN_DESC(TILER_CONTEXT),
|
||||
PAN_DESC(TILER_HEAP));
|
||||
batch->tiler.descs = pan_pool_alloc_desc_aggregate(
|
||||
&cmdbuf->desc_pool.base, PAN_DESC(TILER_CONTEXT), PAN_DESC(TILER_HEAP));
|
||||
STATIC_ASSERT(sizeof(batch->tiler.templ) >=
|
||||
pan_size(TILER_CONTEXT) + pan_size(TILER_HEAP));
|
||||
|
||||
|
|
@ -456,9 +439,7 @@ panvk_per_arch(cmd_prepare_tiler_context)(struct panvk_cmd_buffer *cmdbuf)
|
|||
{
|
||||
const struct pan_fb_info *fbinfo = &cmdbuf->state.fb.info;
|
||||
|
||||
panvk_per_arch(cmd_get_tiler_context)(cmdbuf,
|
||||
fbinfo->width,
|
||||
fbinfo->height);
|
||||
panvk_per_arch(cmd_get_tiler_context)(cmdbuf, fbinfo->width, fbinfo->height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -475,17 +456,16 @@ static void
|
|||
panvk_draw_prepare_varyings(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_info *draw)
|
||||
{
|
||||
const struct panvk_pipeline *pipeline = panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
const struct panvk_pipeline *pipeline =
|
||||
panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
struct panvk_varyings_info *varyings = &cmdbuf->state.varyings;
|
||||
|
||||
panvk_varyings_alloc(varyings, &cmdbuf->varying_pool.base,
|
||||
draw->padded_vertex_count * draw->instance_count);
|
||||
|
||||
unsigned buf_count = panvk_varyings_buf_count(varyings);
|
||||
struct panfrost_ptr bufs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
buf_count + 1,
|
||||
ATTRIBUTE_BUFFER);
|
||||
struct panfrost_ptr bufs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, buf_count + 1, ATTRIBUTE_BUFFER);
|
||||
|
||||
panvk_per_arch(emit_varying_bufs)(varyings, bufs.cpu);
|
||||
|
||||
|
|
@ -494,30 +474,32 @@ panvk_draw_prepare_varyings(struct panvk_cmd_buffer *cmdbuf,
|
|||
pan_size(ATTRIBUTE_BUFFER));
|
||||
|
||||
if (BITSET_TEST(varyings->active, VARYING_SLOT_POS)) {
|
||||
draw->position = varyings->buf[varyings->varying[VARYING_SLOT_POS].buf].address +
|
||||
varyings->varying[VARYING_SLOT_POS].offset;
|
||||
draw->position =
|
||||
varyings->buf[varyings->varying[VARYING_SLOT_POS].buf].address +
|
||||
varyings->varying[VARYING_SLOT_POS].offset;
|
||||
}
|
||||
|
||||
if (pipeline->ia.writes_point_size) {
|
||||
draw->psiz = varyings->buf[varyings->varying[VARYING_SLOT_PSIZ].buf].address +
|
||||
varyings->varying[VARYING_SLOT_POS].offset;
|
||||
draw->psiz =
|
||||
varyings->buf[varyings->varying[VARYING_SLOT_PSIZ].buf].address +
|
||||
varyings->varying[VARYING_SLOT_POS].offset;
|
||||
} else if (pipeline->ia.topology == MALI_DRAW_MODE_LINES ||
|
||||
pipeline->ia.topology == MALI_DRAW_MODE_LINE_STRIP ||
|
||||
pipeline->ia.topology == MALI_DRAW_MODE_LINE_LOOP) {
|
||||
draw->line_width = pipeline->dynamic_state_mask & PANVK_DYNAMIC_LINE_WIDTH ?
|
||||
cmdbuf->state.rast.line_width : pipeline->rast.line_width;
|
||||
draw->line_width = pipeline->dynamic_state_mask & PANVK_DYNAMIC_LINE_WIDTH
|
||||
? cmdbuf->state.rast.line_width
|
||||
: pipeline->rast.line_width;
|
||||
} else {
|
||||
draw->line_width = 1.0f;
|
||||
}
|
||||
draw->varying_bufs = bufs.gpu;
|
||||
|
||||
for (unsigned s = 0; s < MESA_SHADER_STAGES; s++) {
|
||||
if (!varyings->stage[s].count) continue;
|
||||
if (!varyings->stage[s].count)
|
||||
continue;
|
||||
|
||||
struct panfrost_ptr attribs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
varyings->stage[s].count,
|
||||
ATTRIBUTE);
|
||||
struct panfrost_ptr attribs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, varyings->stage[s].count, ATTRIBUTE);
|
||||
|
||||
panvk_per_arch(emit_varyings)(cmdbuf->device, varyings, s, attribs.cpu);
|
||||
draw->stages[s].varyings = attribs.gpu;
|
||||
|
|
@ -527,8 +509,7 @@ panvk_draw_prepare_varyings(struct panvk_cmd_buffer *cmdbuf,
|
|||
static void
|
||||
panvk_fill_non_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_cmd_bind_point_state *bind_point_state,
|
||||
void *attrib_bufs, void *attribs,
|
||||
unsigned first_buf)
|
||||
void *attrib_bufs, void *attribs, unsigned first_buf)
|
||||
{
|
||||
struct panvk_descriptor_state *desc_state = &bind_point_state->desc_state;
|
||||
const struct panvk_pipeline *pipeline = bind_point_state->pipeline;
|
||||
|
|
@ -536,7 +517,8 @@ panvk_fill_non_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
|||
for (unsigned s = 0; s < pipeline->layout->num_sets; s++) {
|
||||
const struct panvk_descriptor_set *set = desc_state->sets[s];
|
||||
|
||||
if (!set) continue;
|
||||
if (!set)
|
||||
continue;
|
||||
|
||||
const struct panvk_descriptor_set_layout *layout = set->layout;
|
||||
unsigned img_idx = pipeline->layout->sets[s].img_offset;
|
||||
|
|
@ -568,15 +550,13 @@ panvk_prepare_non_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
|||
|
||||
unsigned attrib_count = pipeline->layout->num_imgs;
|
||||
unsigned attrib_buf_count = (pipeline->layout->num_imgs * 2);
|
||||
struct panfrost_ptr bufs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
attrib_buf_count + 1,
|
||||
ATTRIBUTE_BUFFER);
|
||||
struct panfrost_ptr attribs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base, attrib_count,
|
||||
ATTRIBUTE);
|
||||
struct panfrost_ptr bufs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, attrib_buf_count + 1, ATTRIBUTE_BUFFER);
|
||||
struct panfrost_ptr attribs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, attrib_count, ATTRIBUTE);
|
||||
|
||||
panvk_fill_non_vs_attribs(cmdbuf, bind_point_state, bufs.cpu, attribs.cpu, 0);
|
||||
panvk_fill_non_vs_attribs(cmdbuf, bind_point_state, bufs.cpu, attribs.cpu,
|
||||
0);
|
||||
|
||||
desc_state->non_vs_attrib_bufs = bufs.gpu;
|
||||
desc_state->non_vs_attribs = attribs.gpu;
|
||||
|
|
@ -591,8 +571,9 @@ panvk_draw_prepare_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct panvk_descriptor_state *desc_state = &bind_point_state->desc_state;
|
||||
const struct panvk_pipeline *pipeline = bind_point_state->pipeline;
|
||||
unsigned num_imgs =
|
||||
pipeline->img_access_mask & BITFIELD_BIT(MESA_SHADER_VERTEX) ?
|
||||
pipeline->layout->num_imgs : 0;
|
||||
pipeline->img_access_mask & BITFIELD_BIT(MESA_SHADER_VERTEX)
|
||||
? pipeline->layout->num_imgs
|
||||
: 0;
|
||||
unsigned attrib_count = pipeline->attribs.attrib_count + num_imgs;
|
||||
|
||||
if (desc_state->vs_attribs || !attrib_count)
|
||||
|
|
@ -606,29 +587,26 @@ panvk_draw_prepare_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
unsigned attrib_buf_count = pipeline->attribs.buf_count * 2;
|
||||
struct panfrost_ptr bufs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base,
|
||||
attrib_buf_count + 1,
|
||||
ATTRIBUTE_BUFFER);
|
||||
struct panfrost_ptr attribs =
|
||||
pan_pool_alloc_desc_array(&cmdbuf->desc_pool.base, attrib_count,
|
||||
ATTRIBUTE);
|
||||
struct panfrost_ptr bufs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, attrib_buf_count + 1, ATTRIBUTE_BUFFER);
|
||||
struct panfrost_ptr attribs = pan_pool_alloc_desc_array(
|
||||
&cmdbuf->desc_pool.base, attrib_count, ATTRIBUTE);
|
||||
|
||||
panvk_per_arch(emit_attrib_bufs)(&pipeline->attribs,
|
||||
cmdbuf->state.vb.bufs,
|
||||
cmdbuf->state.vb.count,
|
||||
draw, bufs.cpu);
|
||||
panvk_per_arch(emit_attrib_bufs)(&pipeline->attribs, cmdbuf->state.vb.bufs,
|
||||
cmdbuf->state.vb.count, draw, bufs.cpu);
|
||||
panvk_per_arch(emit_attribs)(cmdbuf->device, draw, &pipeline->attribs,
|
||||
cmdbuf->state.vb.bufs, cmdbuf->state.vb.count,
|
||||
attribs.cpu);
|
||||
|
||||
if (attrib_count > pipeline->attribs.buf_count) {
|
||||
unsigned bufs_offset = pipeline->attribs.buf_count * pan_size(ATTRIBUTE_BUFFER) * 2;
|
||||
unsigned attribs_offset = pipeline->attribs.buf_count * pan_size(ATTRIBUTE);
|
||||
unsigned bufs_offset =
|
||||
pipeline->attribs.buf_count * pan_size(ATTRIBUTE_BUFFER) * 2;
|
||||
unsigned attribs_offset =
|
||||
pipeline->attribs.buf_count * pan_size(ATTRIBUTE);
|
||||
|
||||
panvk_fill_non_vs_attribs(cmdbuf, bind_point_state,
|
||||
bufs.cpu + bufs_offset, attribs.cpu + attribs_offset,
|
||||
pipeline->attribs.buf_count * 2);
|
||||
panvk_fill_non_vs_attribs(
|
||||
cmdbuf, bind_point_state, bufs.cpu + bufs_offset,
|
||||
attribs.cpu + attribs_offset, pipeline->attribs.buf_count * 2);
|
||||
}
|
||||
|
||||
/* A NULL entry is needed to stop prefecting on Bifrost */
|
||||
|
|
@ -665,7 +643,8 @@ static void
|
|||
panvk_draw_prepare_viewport(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_info *draw)
|
||||
{
|
||||
const struct panvk_pipeline *pipeline = panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
const struct panvk_pipeline *pipeline =
|
||||
panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
|
||||
if (pipeline->vpd) {
|
||||
draw->viewport = pipeline->vpd;
|
||||
|
|
@ -676,11 +655,13 @@ panvk_draw_prepare_viewport(struct panvk_cmd_buffer *cmdbuf,
|
|||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, VIEWPORT);
|
||||
|
||||
const VkViewport *viewport =
|
||||
pipeline->dynamic_state_mask & PANVK_DYNAMIC_VIEWPORT ?
|
||||
&cmdbuf->state.viewport : &pipeline->viewport;
|
||||
pipeline->dynamic_state_mask & PANVK_DYNAMIC_VIEWPORT
|
||||
? &cmdbuf->state.viewport
|
||||
: &pipeline->viewport;
|
||||
const VkRect2D *scissor =
|
||||
pipeline->dynamic_state_mask & PANVK_DYNAMIC_SCISSOR ?
|
||||
&cmdbuf->state.scissor : &pipeline->scissor;
|
||||
pipeline->dynamic_state_mask & PANVK_DYNAMIC_SCISSOR
|
||||
? &cmdbuf->state.scissor
|
||||
: &pipeline->scissor;
|
||||
|
||||
panvk_per_arch(emit_viewport)(viewport, scissor, vp.cpu);
|
||||
draw->viewport = cmdbuf->state.vpd = vp.gpu;
|
||||
|
|
@ -691,7 +672,8 @@ static void
|
|||
panvk_draw_prepare_vertex_job(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_info *draw)
|
||||
{
|
||||
const struct panvk_pipeline *pipeline = panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
const struct panvk_pipeline *pipeline =
|
||||
panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
struct panvk_batch *batch = cmdbuf->state.batch;
|
||||
struct panfrost_ptr ptr =
|
||||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, COMPUTE_JOB);
|
||||
|
|
@ -705,7 +687,8 @@ static void
|
|||
panvk_draw_prepare_tiler_job(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_info *draw)
|
||||
{
|
||||
const struct panvk_pipeline *pipeline = panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
const struct panvk_pipeline *pipeline =
|
||||
panvk_cmd_get_pipeline(cmdbuf, GRAPHICS);
|
||||
struct panvk_batch *batch = cmdbuf->state.batch;
|
||||
struct panfrost_ptr ptr =
|
||||
pan_pool_alloc_desc(&cmdbuf->desc_pool.base, TILER_JOB);
|
||||
|
|
@ -716,8 +699,7 @@ panvk_draw_prepare_tiler_job(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_cmd_draw(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_info *draw)
|
||||
panvk_cmd_draw(struct panvk_cmd_buffer *cmdbuf, struct panvk_draw_info *draw)
|
||||
{
|
||||
struct panvk_batch *batch = cmdbuf->state.batch;
|
||||
struct panvk_cmd_bind_point_state *bind_point_state =
|
||||
|
|
@ -754,10 +736,11 @@ panvk_cmd_draw(struct panvk_cmd_buffer *cmdbuf,
|
|||
draw->textures = desc_state->textures;
|
||||
draw->samplers = desc_state->samplers;
|
||||
|
||||
STATIC_ASSERT(sizeof(draw->invocation) >= sizeof(struct mali_invocation_packed));
|
||||
panfrost_pack_work_groups_compute((struct mali_invocation_packed *)&draw->invocation,
|
||||
1, draw->vertex_range, draw->instance_count,
|
||||
1, 1, 1, true, false);
|
||||
STATIC_ASSERT(sizeof(draw->invocation) >=
|
||||
sizeof(struct mali_invocation_packed));
|
||||
panfrost_pack_work_groups_compute(
|
||||
(struct mali_invocation_packed *)&draw->invocation, 1, draw->vertex_range,
|
||||
draw->instance_count, 1, 1, 1, true, false);
|
||||
|
||||
panvk_draw_prepare_fs_rsd(cmdbuf, draw);
|
||||
panvk_draw_prepare_varyings(cmdbuf, draw);
|
||||
|
|
@ -769,10 +752,9 @@ panvk_cmd_draw(struct panvk_cmd_buffer *cmdbuf,
|
|||
batch->tlsinfo.tls.size = MAX2(pipeline->tls_size, batch->tlsinfo.tls.size);
|
||||
assert(!pipeline->wls_size);
|
||||
|
||||
unsigned vjob_id =
|
||||
panfrost_add_job(&cmdbuf->desc_pool.base, &batch->scoreboard,
|
||||
MALI_JOB_TYPE_VERTEX, false, false, 0, 0,
|
||||
&draw->jobs.vertex, false);
|
||||
unsigned vjob_id = panfrost_add_job(
|
||||
&cmdbuf->desc_pool.base, &batch->scoreboard, MALI_JOB_TYPE_VERTEX, false,
|
||||
false, 0, 0, &draw->jobs.vertex, false);
|
||||
|
||||
if (pipeline->rast.enable) {
|
||||
panfrost_add_job(&cmdbuf->desc_pool.base, &batch->scoreboard,
|
||||
|
|
@ -785,10 +767,8 @@ panvk_cmd_draw(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdDraw)(VkCommandBuffer commandBuffer,
|
||||
uint32_t vertexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
panvk_per_arch(CmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount,
|
||||
uint32_t instanceCount, uint32_t firstVertex,
|
||||
uint32_t firstInstance)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -802,9 +782,9 @@ panvk_per_arch(CmdDraw)(VkCommandBuffer commandBuffer,
|
|||
.vertex_range = vertexCount,
|
||||
.first_instance = firstInstance,
|
||||
.instance_count = instanceCount,
|
||||
.padded_vertex_count = instanceCount > 1 ?
|
||||
panfrost_padded_vertex_count(vertexCount) :
|
||||
vertexCount,
|
||||
.padded_vertex_count = instanceCount > 1
|
||||
? panfrost_padded_vertex_count(vertexCount)
|
||||
: vertexCount,
|
||||
.offset_start = firstVertex,
|
||||
};
|
||||
|
||||
|
|
@ -812,16 +792,16 @@ panvk_per_arch(CmdDraw)(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_index_minmax_search(struct panvk_cmd_buffer *cmdbuf,
|
||||
uint32_t start, uint32_t count,
|
||||
bool restart,
|
||||
uint32_t *min, uint32_t *max)
|
||||
panvk_index_minmax_search(struct panvk_cmd_buffer *cmdbuf, uint32_t start,
|
||||
uint32_t count, bool restart, uint32_t *min,
|
||||
uint32_t *max)
|
||||
{
|
||||
void *ptr = cmdbuf->state.ib.buffer->bo->ptr.cpu +
|
||||
cmdbuf->state.ib.buffer->bo_offset +
|
||||
cmdbuf->state.ib.offset;
|
||||
cmdbuf->state.ib.buffer->bo_offset + cmdbuf->state.ib.offset;
|
||||
|
||||
fprintf(stderr, "WARNING: Crawling index buffers from the CPU isn't valid in Vulkan\n");
|
||||
fprintf(
|
||||
stderr,
|
||||
"WARNING: Crawling index buffers from the CPU isn't valid in Vulkan\n");
|
||||
|
||||
assert(cmdbuf->state.ib.buffer);
|
||||
assert(cmdbuf->state.ib.buffer->bo);
|
||||
|
|
@ -834,20 +814,21 @@ panvk_index_minmax_search(struct panvk_cmd_buffer *cmdbuf,
|
|||
* mapping slowness.
|
||||
*/
|
||||
switch (cmdbuf->state.ib.index_size) {
|
||||
#define MINMAX_SEARCH_CASE(sz) \
|
||||
case sz: { \
|
||||
uint ## sz ## _t *indices = ptr; \
|
||||
*min = UINT ## sz ## _MAX; \
|
||||
for (uint32_t i = 0; i < count; i++) { \
|
||||
if (restart && indices[i + start] == UINT ## sz ##_MAX) continue; \
|
||||
*min = MIN2(indices[i + start], *min); \
|
||||
*max = MAX2(indices[i + start], *max); \
|
||||
} \
|
||||
break; \
|
||||
#define MINMAX_SEARCH_CASE(sz) \
|
||||
case sz: { \
|
||||
uint##sz##_t *indices = ptr; \
|
||||
*min = UINT##sz##_MAX; \
|
||||
for (uint32_t i = 0; i < count; i++) { \
|
||||
if (restart && indices[i + start] == UINT##sz##_MAX) \
|
||||
continue; \
|
||||
*min = MIN2(indices[i + start], *min); \
|
||||
*max = MAX2(indices[i + start], *max); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
MINMAX_SEARCH_CASE(32)
|
||||
MINMAX_SEARCH_CASE(16)
|
||||
MINMAX_SEARCH_CASE(8)
|
||||
MINMAX_SEARCH_CASE(32)
|
||||
MINMAX_SEARCH_CASE(16)
|
||||
MINMAX_SEARCH_CASE(8)
|
||||
#undef MINMAX_SEARCH_CASE
|
||||
default:
|
||||
unreachable("Invalid index size");
|
||||
|
|
@ -856,10 +837,8 @@ panvk_index_minmax_search(struct panvk_cmd_buffer *cmdbuf,
|
|||
|
||||
void
|
||||
panvk_per_arch(CmdDrawIndexed)(VkCommandBuffer commandBuffer,
|
||||
uint32_t indexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstIndex,
|
||||
int32_t vertexOffset,
|
||||
uint32_t indexCount, uint32_t instanceCount,
|
||||
uint32_t firstIndex, int32_t vertexOffset,
|
||||
uint32_t firstInstance)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -885,9 +864,9 @@ panvk_per_arch(CmdDrawIndexed)(VkCommandBuffer commandBuffer,
|
|||
.instance_count = instanceCount,
|
||||
.vertex_range = vertex_range,
|
||||
.vertex_count = indexCount + abs(vertexOffset),
|
||||
.padded_vertex_count = instanceCount > 1 ?
|
||||
panfrost_padded_vertex_count(vertex_range) :
|
||||
vertex_range,
|
||||
.padded_vertex_count = instanceCount > 1
|
||||
? panfrost_padded_vertex_count(vertex_range)
|
||||
: vertex_range,
|
||||
.offset_start = min_vertex + vertexOffset,
|
||||
.indices = panvk_buffer_gpu_ptr(cmdbuf->state.ib.buffer,
|
||||
cmdbuf->state.ib.offset) +
|
||||
|
|
@ -932,7 +911,6 @@ panvk_per_arch(CmdEndRenderPass)(VkCommandBuffer cmd)
|
|||
panvk_per_arch(CmdEndRenderPass2)(cmd, &einfo);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdPipelineBarrier2)(VkCommandBuffer commandBuffer,
|
||||
const VkDependencyInfo *pDependencyInfo)
|
||||
|
|
@ -968,16 +946,14 @@ panvk_add_set_event_operation(struct panvk_cmd_buffer *cmdbuf,
|
|||
*/
|
||||
panvk_cmd_open_batch(cmdbuf);
|
||||
util_dynarray_append(&cmdbuf->state.batch->event_ops,
|
||||
struct panvk_event_op,
|
||||
op);
|
||||
struct panvk_event_op, op);
|
||||
panvk_per_arch(cmd_close_batch)(cmdbuf);
|
||||
} else {
|
||||
/* Let's close the current batch so the operation executes before any
|
||||
* future commands.
|
||||
*/
|
||||
util_dynarray_append(&cmdbuf->state.batch->event_ops,
|
||||
struct panvk_event_op,
|
||||
op);
|
||||
struct panvk_event_op, op);
|
||||
panvk_per_arch(cmd_close_batch)(cmdbuf);
|
||||
panvk_cmd_preload_fb_after_batch_split(cmdbuf);
|
||||
panvk_cmd_open_batch(cmdbuf);
|
||||
|
|
@ -997,8 +973,7 @@ panvk_add_wait_event_operation(struct panvk_cmd_buffer *cmdbuf,
|
|||
/* No open batch, let's create a new one and have it wait for this event. */
|
||||
panvk_cmd_open_batch(cmdbuf);
|
||||
util_dynarray_append(&cmdbuf->state.batch->event_ops,
|
||||
struct panvk_event_op,
|
||||
op);
|
||||
struct panvk_event_op, op);
|
||||
} else {
|
||||
/* Let's close the current batch so any future commands wait on the
|
||||
* event signal operation.
|
||||
|
|
@ -1010,14 +985,12 @@ panvk_add_wait_event_operation(struct panvk_cmd_buffer *cmdbuf,
|
|||
panvk_cmd_open_batch(cmdbuf);
|
||||
}
|
||||
util_dynarray_append(&cmdbuf->state.batch->event_ops,
|
||||
struct panvk_event_op,
|
||||
op);
|
||||
struct panvk_event_op, op);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdSetEvent2)(VkCommandBuffer commandBuffer,
|
||||
VkEvent _event,
|
||||
panvk_per_arch(CmdSetEvent2)(VkCommandBuffer commandBuffer, VkEvent _event,
|
||||
const VkDependencyInfo *pDependencyInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -1030,8 +1003,7 @@ panvk_per_arch(CmdSetEvent2)(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdResetEvent2)(VkCommandBuffer commandBuffer,
|
||||
VkEvent _event,
|
||||
panvk_per_arch(CmdResetEvent2)(VkCommandBuffer commandBuffer, VkEvent _event,
|
||||
VkPipelineStageFlags2 stageMask)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -1045,8 +1017,7 @@ panvk_per_arch(CmdResetEvent2)(VkCommandBuffer commandBuffer,
|
|||
|
||||
void
|
||||
panvk_per_arch(CmdWaitEvents2)(VkCommandBuffer commandBuffer,
|
||||
uint32_t eventCount,
|
||||
const VkEvent *pEvents,
|
||||
uint32_t eventCount, const VkEvent *pEvents,
|
||||
const VkDependencyInfo *pDependencyInfos)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
|
|
@ -1081,7 +1052,8 @@ panvk_reset_cmdbuf(struct vk_command_buffer *vk_cmdbuf,
|
|||
panvk_pool_reset(&cmdbuf->varying_pool);
|
||||
|
||||
for (unsigned i = 0; i < MAX_BIND_POINTS; i++)
|
||||
memset(&cmdbuf->bind_points[i].desc_state.sets, 0, sizeof(cmdbuf->bind_points[0].desc_state.sets));
|
||||
memset(&cmdbuf->bind_points[i].desc_state.sets, 0,
|
||||
sizeof(cmdbuf->bind_points[0].desc_state.sets));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1116,8 +1088,8 @@ panvk_create_cmdbuf(struct vk_command_pool *vk_pool,
|
|||
container_of(vk_pool, struct panvk_cmd_pool, vk);
|
||||
struct panvk_cmd_buffer *cmdbuf;
|
||||
|
||||
cmdbuf = vk_zalloc(&device->vk.alloc, sizeof(*cmdbuf),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
cmdbuf = vk_zalloc(&device->vk.alloc, sizeof(*cmdbuf), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (!cmdbuf)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
@ -1166,8 +1138,7 @@ panvk_per_arch(BeginCommandBuffer)(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(DestroyCommandPool)(VkDevice _device,
|
||||
VkCommandPool commandPool,
|
||||
panvk_per_arch(DestroyCommandPool)(VkDevice _device, VkCommandPool commandPool,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
|
|
@ -1183,16 +1154,13 @@ panvk_per_arch(DestroyCommandPool)(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdDispatch)(VkCommandBuffer commandBuffer,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t z)
|
||||
panvk_per_arch(CmdDispatch)(VkCommandBuffer commandBuffer, uint32_t x,
|
||||
uint32_t y, uint32_t z)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
const struct panfrost_device *pdev =
|
||||
&cmdbuf->device->physical_device->pdev;
|
||||
const struct panfrost_device *pdev = &cmdbuf->device->physical_device->pdev;
|
||||
struct panvk_dispatch_info dispatch = {
|
||||
.wg_count = { x, y, z },
|
||||
.wg_count = {x, y, z},
|
||||
};
|
||||
|
||||
panvk_per_arch(cmd_close_batch)(cmdbuf);
|
||||
|
|
@ -1232,8 +1200,7 @@ panvk_per_arch(CmdDispatch)(VkCommandBuffer commandBuffer,
|
|||
|
||||
panvk_per_arch(emit_compute_job)(pipeline, &dispatch, job.cpu);
|
||||
panfrost_add_job(&cmdbuf->desc_pool.base, &batch->scoreboard,
|
||||
MALI_JOB_TYPE_COMPUTE, false, false, 0, 0,
|
||||
&job, false);
|
||||
MALI_JOB_TYPE_COMPUTE, false, false, 0, 0, &job, false);
|
||||
|
||||
batch->tlsinfo.tls.size = pipeline->tls_size;
|
||||
batch->tlsinfo.wls.size = pipeline->wls_size;
|
||||
|
|
|
|||
|
|
@ -29,24 +29,19 @@
|
|||
#error "no arch"
|
||||
#endif
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "compiler/shader_enums.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
extern const struct vk_command_buffer_ops panvk_per_arch(cmd_buffer_ops);
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_close_batch)(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_per_arch(cmd_close_batch)(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void panvk_per_arch(cmd_get_tiler_context)(struct panvk_cmd_buffer *cmdbuf,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_get_tiler_context)(struct panvk_cmd_buffer *cmdbuf,
|
||||
unsigned width, unsigned height);
|
||||
void panvk_per_arch(cmd_alloc_fb_desc)(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_alloc_fb_desc)(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_per_arch(cmd_alloc_tls_desc)(struct panvk_cmd_buffer *cmdbuf,
|
||||
bool gfx);
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_alloc_tls_desc)(struct panvk_cmd_buffer *cmdbuf, bool gfx);
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_prepare_tiler_context)(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_per_arch(cmd_prepare_tiler_context)(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@
|
|||
|
||||
#include "genxml/gen_macros.h"
|
||||
|
||||
#include "util/macros.h"
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
#include "vk_util.h"
|
||||
|
||||
#include "pan_cs.h"
|
||||
#include "pan_earlyzs.h"
|
||||
#include "pan_encoder.h"
|
||||
#include "pan_pool.h"
|
||||
#include "pan_shader.h"
|
||||
#include "pan_earlyzs.h"
|
||||
|
||||
#include "panvk_cs.h"
|
||||
#include "panvk_private.h"
|
||||
|
|
@ -44,9 +44,12 @@ static enum mali_mipmap_mode
|
|||
panvk_translate_sampler_mipmap_mode(VkSamplerMipmapMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case VK_SAMPLER_MIPMAP_MODE_NEAREST: return MALI_MIPMAP_MODE_NEAREST;
|
||||
case VK_SAMPLER_MIPMAP_MODE_LINEAR: return MALI_MIPMAP_MODE_TRILINEAR;
|
||||
default: unreachable("Invalid mipmap mode");
|
||||
case VK_SAMPLER_MIPMAP_MODE_NEAREST:
|
||||
return MALI_MIPMAP_MODE_NEAREST;
|
||||
case VK_SAMPLER_MIPMAP_MODE_LINEAR:
|
||||
return MALI_MIPMAP_MODE_TRILINEAR;
|
||||
default:
|
||||
unreachable("Invalid mipmap mode");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,12 +57,18 @@ static unsigned
|
|||
panvk_translate_sampler_address_mode(VkSamplerAddressMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case VK_SAMPLER_ADDRESS_MODE_REPEAT: return MALI_WRAP_MODE_REPEAT;
|
||||
case VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT: return MALI_WRAP_MODE_MIRRORED_REPEAT;
|
||||
case VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE: return MALI_WRAP_MODE_CLAMP_TO_EDGE;
|
||||
case VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER: return MALI_WRAP_MODE_CLAMP_TO_BORDER;
|
||||
case VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE: return MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE;
|
||||
default: unreachable("Invalid wrap");
|
||||
case VK_SAMPLER_ADDRESS_MODE_REPEAT:
|
||||
return MALI_WRAP_MODE_REPEAT;
|
||||
case VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT:
|
||||
return MALI_WRAP_MODE_MIRRORED_REPEAT;
|
||||
case VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE:
|
||||
return MALI_WRAP_MODE_CLAMP_TO_EDGE;
|
||||
case VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER:
|
||||
return MALI_WRAP_MODE_CLAMP_TO_BORDER;
|
||||
case VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE:
|
||||
return MALI_WRAP_MODE_MIRRORED_CLAMP_TO_EDGE;
|
||||
default:
|
||||
unreachable("Invalid wrap");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +108,7 @@ panvk_varying_hw_format(const struct panvk_device *dev,
|
|||
static void
|
||||
panvk_emit_varying(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage, unsigned idx,
|
||||
void *attrib)
|
||||
gl_shader_stage stage, unsigned idx, void *attrib)
|
||||
{
|
||||
gl_varying_slot loc = varyings->stage[stage].loc[idx];
|
||||
|
||||
|
|
@ -114,8 +122,7 @@ panvk_emit_varying(const struct panvk_device *dev,
|
|||
void
|
||||
panvk_per_arch(emit_varyings)(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage,
|
||||
void *descs)
|
||||
gl_shader_stage stage, void *descs)
|
||||
{
|
||||
struct mali_attribute_packed *attrib = descs;
|
||||
|
||||
|
|
@ -153,8 +160,7 @@ panvk_per_arch(emit_varying_bufs)(const struct panvk_varyings_info *varyings,
|
|||
static void
|
||||
panvk_emit_attrib_buf(const struct panvk_attribs_info *info,
|
||||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
const struct panvk_attrib_buf *bufs, unsigned buf_count,
|
||||
unsigned idx, void *desc)
|
||||
{
|
||||
const struct panvk_attrib_buf_info *buf_info = &info->buf[idx];
|
||||
|
|
@ -163,8 +169,7 @@ panvk_emit_attrib_buf(const struct panvk_attribs_info *info,
|
|||
const struct panvk_attrib_buf *buf = &bufs[idx];
|
||||
mali_ptr addr = buf->address & ~63ULL;
|
||||
unsigned size = buf->size + (buf->address & 63);
|
||||
unsigned divisor =
|
||||
draw->padded_vertex_count * buf_info->instance_divisor;
|
||||
unsigned divisor = draw->padded_vertex_count * buf_info->instance_divisor;
|
||||
|
||||
/* TODO: support instanced arrays */
|
||||
if (draw->instance_count <= 1) {
|
||||
|
|
@ -237,8 +242,7 @@ panvk_per_arch(emit_attrib_bufs)(const struct panvk_attribs_info *info,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_sampler)(const VkSamplerCreateInfo *pCreateInfo,
|
||||
void *desc)
|
||||
panvk_per_arch(emit_sampler)(const VkSamplerCreateInfo *pCreateInfo, void *desc)
|
||||
{
|
||||
VkClearColorValue border_color =
|
||||
vk_sampler_border_color_value(pCreateInfo, NULL);
|
||||
|
|
@ -246,16 +250,21 @@ panvk_per_arch(emit_sampler)(const VkSamplerCreateInfo *pCreateInfo,
|
|||
pan_pack(desc, SAMPLER, cfg) {
|
||||
cfg.magnify_nearest = pCreateInfo->magFilter == VK_FILTER_NEAREST;
|
||||
cfg.minify_nearest = pCreateInfo->minFilter == VK_FILTER_NEAREST;
|
||||
cfg.mipmap_mode = panvk_translate_sampler_mipmap_mode(pCreateInfo->mipmapMode);
|
||||
cfg.mipmap_mode =
|
||||
panvk_translate_sampler_mipmap_mode(pCreateInfo->mipmapMode);
|
||||
cfg.normalized_coordinates = !pCreateInfo->unnormalizedCoordinates;
|
||||
|
||||
cfg.lod_bias = pCreateInfo->mipLodBias;
|
||||
cfg.minimum_lod = pCreateInfo->minLod;
|
||||
cfg.maximum_lod = pCreateInfo->maxLod;
|
||||
cfg.wrap_mode_s = panvk_translate_sampler_address_mode(pCreateInfo->addressModeU);
|
||||
cfg.wrap_mode_t = panvk_translate_sampler_address_mode(pCreateInfo->addressModeV);
|
||||
cfg.wrap_mode_r = panvk_translate_sampler_address_mode(pCreateInfo->addressModeW);
|
||||
cfg.compare_function = panvk_per_arch(translate_sampler_compare_func)(pCreateInfo);
|
||||
cfg.wrap_mode_s =
|
||||
panvk_translate_sampler_address_mode(pCreateInfo->addressModeU);
|
||||
cfg.wrap_mode_t =
|
||||
panvk_translate_sampler_address_mode(pCreateInfo->addressModeV);
|
||||
cfg.wrap_mode_r =
|
||||
panvk_translate_sampler_address_mode(pCreateInfo->addressModeW);
|
||||
cfg.compare_function =
|
||||
panvk_per_arch(translate_sampler_compare_func)(pCreateInfo);
|
||||
cfg.border_color_r = border_color.uint32[0];
|
||||
cfg.border_color_g = border_color.uint32[1];
|
||||
cfg.border_color_b = border_color.uint32[2];
|
||||
|
|
@ -267,8 +276,7 @@ static void
|
|||
panvk_emit_attrib(const struct panvk_device *dev,
|
||||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_attribs_info *attribs,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
const struct panvk_attrib_buf *bufs, unsigned buf_count,
|
||||
unsigned idx, void *attrib)
|
||||
{
|
||||
const struct panfrost_device *pdev = &dev->physical_device->pdev;
|
||||
|
|
@ -277,8 +285,7 @@ panvk_emit_attrib(const struct panvk_device *dev,
|
|||
|
||||
pan_pack(attrib, ATTRIBUTE, cfg) {
|
||||
cfg.buffer_index = buf_idx * 2;
|
||||
cfg.offset = attribs->attrib[idx].offset +
|
||||
(bufs[buf_idx].address & 63);
|
||||
cfg.offset = attribs->attrib[idx].offset + (bufs[buf_idx].address & 63);
|
||||
|
||||
if (buf_info->per_instance)
|
||||
cfg.offset += draw->first_instance * buf_info->stride;
|
||||
|
|
@ -292,8 +299,7 @@ panvk_per_arch(emit_attribs)(const struct panvk_device *dev,
|
|||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_attribs_info *attribs,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
void *descs)
|
||||
unsigned buf_count, void *descs)
|
||||
{
|
||||
struct mali_attribute_packed *attrib = descs;
|
||||
|
||||
|
|
@ -302,7 +308,7 @@ panvk_per_arch(emit_attribs)(const struct panvk_device *dev,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_ubo)(mali_ptr address, size_t size, void *desc)
|
||||
panvk_per_arch(emit_ubo)(mali_ptr address, size_t size, void *desc)
|
||||
{
|
||||
pan_pack(desc, UNIFORM_BUFFER, cfg) {
|
||||
cfg.pointer = address;
|
||||
|
|
@ -317,14 +323,14 @@ panvk_per_arch(emit_ubos)(const struct panvk_pipeline *pipeline,
|
|||
{
|
||||
struct mali_uniform_buffer_packed *ubos = descs;
|
||||
|
||||
panvk_per_arch(emit_ubo)(state->sysvals_ptr,
|
||||
sizeof(state->sysvals),
|
||||
panvk_per_arch(emit_ubo)(state->sysvals_ptr, sizeof(state->sysvals),
|
||||
&ubos[PANVK_SYSVAL_UBO_INDEX]);
|
||||
|
||||
if (pipeline->layout->push_constants.size) {
|
||||
panvk_per_arch(emit_ubo)(state->push_constants,
|
||||
ALIGN_POT(pipeline->layout->push_constants.size, 16),
|
||||
&ubos[PANVK_PUSH_CONST_UBO_INDEX]);
|
||||
panvk_per_arch(emit_ubo)(
|
||||
state->push_constants,
|
||||
ALIGN_POT(pipeline->layout->push_constants.size, 16),
|
||||
&ubos[PANVK_PUSH_CONST_UBO_INDEX]);
|
||||
} else {
|
||||
memset(&ubos[PANVK_PUSH_CONST_UBO_INDEX], 0, sizeof(*ubos));
|
||||
}
|
||||
|
|
@ -351,10 +357,10 @@ panvk_per_arch(emit_ubos)(const struct panvk_pipeline *pipeline,
|
|||
const struct panvk_buffer_desc *bdesc =
|
||||
&state->dyn.ubos[pipeline->layout->sets[s].dyn_ubo_offset + i];
|
||||
|
||||
mali_ptr address = panvk_buffer_gpu_ptr(bdesc->buffer,
|
||||
bdesc->offset);
|
||||
size_t size = panvk_buffer_range(bdesc->buffer,
|
||||
bdesc->offset, bdesc->size);
|
||||
mali_ptr address =
|
||||
panvk_buffer_gpu_ptr(bdesc->buffer, bdesc->offset);
|
||||
size_t size =
|
||||
panvk_buffer_range(bdesc->buffer, bdesc->offset, bdesc->size);
|
||||
if (size) {
|
||||
panvk_per_arch(emit_ubo)(address, size,
|
||||
&ubos[dyn_ubo_start + i]);
|
||||
|
|
@ -368,8 +374,7 @@ panvk_per_arch(emit_ubos)(const struct panvk_pipeline *pipeline,
|
|||
|
||||
void
|
||||
panvk_per_arch(emit_vertex_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job)
|
||||
const struct panvk_draw_info *draw, void *job)
|
||||
{
|
||||
void *section = pan_section_ptr(job, COMPUTE_JOB, INVOCATION);
|
||||
|
||||
|
|
@ -387,8 +392,8 @@ panvk_per_arch(emit_vertex_job)(const struct panvk_pipeline *pipeline,
|
|||
cfg.varying_buffers = draw->varying_bufs;
|
||||
cfg.thread_storage = draw->tls;
|
||||
cfg.offset_start = draw->offset_start;
|
||||
cfg.instance_size = draw->instance_count > 1 ?
|
||||
draw->padded_vertex_count : 1;
|
||||
cfg.instance_size =
|
||||
draw->instance_count > 1 ? draw->padded_vertex_count : 1;
|
||||
cfg.uniform_buffers = draw->ubos;
|
||||
cfg.push_uniforms = draw->stages[PIPE_SHADER_VERTEX].push_constants;
|
||||
cfg.textures = draw->textures;
|
||||
|
|
@ -401,20 +406,15 @@ panvk_per_arch(emit_compute_job)(const struct panvk_pipeline *pipeline,
|
|||
const struct panvk_dispatch_info *dispatch,
|
||||
void *job)
|
||||
{
|
||||
panfrost_pack_work_groups_compute(pan_section_ptr(job, COMPUTE_JOB, INVOCATION),
|
||||
dispatch->wg_count.x,
|
||||
dispatch->wg_count.y,
|
||||
dispatch->wg_count.z,
|
||||
pipeline->cs.local_size.x,
|
||||
pipeline->cs.local_size.y,
|
||||
pipeline->cs.local_size.z,
|
||||
false, false);
|
||||
panfrost_pack_work_groups_compute(
|
||||
pan_section_ptr(job, COMPUTE_JOB, INVOCATION), dispatch->wg_count.x,
|
||||
dispatch->wg_count.y, dispatch->wg_count.z, pipeline->cs.local_size.x,
|
||||
pipeline->cs.local_size.y, pipeline->cs.local_size.z, false, false);
|
||||
|
||||
pan_section_pack(job, COMPUTE_JOB, PARAMETERS, cfg) {
|
||||
cfg.job_task_split =
|
||||
util_logbase2_ceil(pipeline->cs.local_size.x + 1) +
|
||||
util_logbase2_ceil(pipeline->cs.local_size.y + 1) +
|
||||
util_logbase2_ceil(pipeline->cs.local_size.z + 1);
|
||||
cfg.job_task_split = util_logbase2_ceil(pipeline->cs.local_size.x + 1) +
|
||||
util_logbase2_ceil(pipeline->cs.local_size.y + 1) +
|
||||
util_logbase2_ceil(pipeline->cs.local_size.z + 1);
|
||||
}
|
||||
|
||||
pan_section_pack(job, COMPUTE_JOB, DRAW, cfg) {
|
||||
|
|
@ -431,8 +431,7 @@ panvk_per_arch(emit_compute_job)(const struct panvk_pipeline *pipeline,
|
|||
|
||||
static void
|
||||
panvk_emit_tiler_primitive(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *prim)
|
||||
const struct panvk_draw_info *draw, void *prim)
|
||||
{
|
||||
pan_pack(prim, PRIMITIVE, cfg) {
|
||||
cfg.draw_mode = pipeline->ia.topology;
|
||||
|
|
@ -450,10 +449,17 @@ panvk_emit_tiler_primitive(const struct panvk_pipeline *pipeline,
|
|||
cfg.base_vertex_offset = draw->vertex_offset - draw->offset_start;
|
||||
|
||||
switch (draw->index_size) {
|
||||
case 32: cfg.index_type = MALI_INDEX_TYPE_UINT32; break;
|
||||
case 16: cfg.index_type = MALI_INDEX_TYPE_UINT16; break;
|
||||
case 8: cfg.index_type = MALI_INDEX_TYPE_UINT8; break;
|
||||
default: unreachable("Invalid index size");
|
||||
case 32:
|
||||
cfg.index_type = MALI_INDEX_TYPE_UINT32;
|
||||
break;
|
||||
case 16:
|
||||
cfg.index_type = MALI_INDEX_TYPE_UINT16;
|
||||
break;
|
||||
case 8:
|
||||
cfg.index_type = MALI_INDEX_TYPE_UINT8;
|
||||
break;
|
||||
default:
|
||||
unreachable("Invalid index size");
|
||||
}
|
||||
} else {
|
||||
cfg.index_count = draw->vertex_count;
|
||||
|
|
@ -478,8 +484,7 @@ panvk_emit_tiler_primitive_size(const struct panvk_pipeline *pipeline,
|
|||
|
||||
static void
|
||||
panvk_emit_tiler_dcd(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *dcd)
|
||||
const struct panvk_draw_info *draw, void *dcd)
|
||||
{
|
||||
pan_pack(dcd, DRAW, cfg) {
|
||||
cfg.front_face_ccw = pipeline->rast.front_ccw;
|
||||
|
|
@ -505,8 +510,8 @@ panvk_emit_tiler_dcd(const struct panvk_pipeline *pipeline,
|
|||
}
|
||||
|
||||
cfg.offset_start = draw->offset_start;
|
||||
cfg.instance_size = draw->instance_count > 1 ?
|
||||
draw->padded_vertex_count : 1;
|
||||
cfg.instance_size =
|
||||
draw->instance_count > 1 ? draw->padded_vertex_count : 1;
|
||||
cfg.uniform_buffers = draw->ubos;
|
||||
cfg.push_uniforms = draw->stages[PIPE_SHADER_FRAGMENT].push_constants;
|
||||
cfg.textures = draw->textures;
|
||||
|
|
@ -518,8 +523,7 @@ panvk_emit_tiler_dcd(const struct panvk_pipeline *pipeline,
|
|||
|
||||
void
|
||||
panvk_per_arch(emit_tiler_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job)
|
||||
const struct panvk_draw_info *draw, void *job)
|
||||
{
|
||||
void *section;
|
||||
|
||||
|
|
@ -538,13 +542,13 @@ panvk_per_arch(emit_tiler_job)(const struct panvk_pipeline *pipeline,
|
|||
pan_section_pack(job, TILER_JOB, TILER, cfg) {
|
||||
cfg.address = draw->tiler_ctx->bifrost;
|
||||
}
|
||||
pan_section_pack(job, TILER_JOB, PADDING, padding);
|
||||
pan_section_pack(job, TILER_JOB, PADDING, padding)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_viewport)(const VkViewport *viewport,
|
||||
const VkRect2D *scissor,
|
||||
void *vpd)
|
||||
const VkRect2D *scissor, void *vpd)
|
||||
{
|
||||
/* The spec says "width must be greater than 0.0" */
|
||||
assert(viewport->x >= 0);
|
||||
|
|
@ -581,7 +585,7 @@ panvk_per_arch(emit_viewport)(const VkViewport *viewport,
|
|||
static enum mali_register_file_format
|
||||
bifrost_blend_type_from_nir(nir_alu_type nir_type)
|
||||
{
|
||||
switch(nir_type) {
|
||||
switch (nir_type) {
|
||||
case 0: /* Render target not in use */
|
||||
return 0;
|
||||
case nir_type_float16:
|
||||
|
|
@ -603,8 +607,8 @@ bifrost_blend_type_from_nir(nir_alu_type nir_type)
|
|||
|
||||
void
|
||||
panvk_per_arch(emit_blend)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
unsigned rt, void *bd)
|
||||
const struct panvk_pipeline *pipeline, unsigned rt,
|
||||
void *bd)
|
||||
{
|
||||
const struct pan_blend_state *blend = &pipeline->blend.state;
|
||||
const struct pan_blend_rt_state *rts = &blend->rts[rt];
|
||||
|
|
@ -632,9 +636,8 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev,
|
|||
&cfg.equation);
|
||||
|
||||
/* Fixed point constant */
|
||||
float fconst =
|
||||
pan_blend_get_constant(pan_blend_constant_mask(blend->rts[rt].equation),
|
||||
blend->constants);
|
||||
float fconst = pan_blend_get_constant(
|
||||
pan_blend_constant_mask(blend->rts[rt].equation), blend->constants);
|
||||
u16 constant = fconst * ((1 << chan_size) - 1);
|
||||
constant <<= 16 - chan_size;
|
||||
cfg.constant = constant;
|
||||
|
|
@ -645,9 +648,9 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev,
|
|||
cfg.internal.mode = MALI_BLEND_MODE_FIXED_FUNCTION;
|
||||
|
||||
cfg.internal.fixed_function.alpha_zero_nop =
|
||||
pan_blend_alpha_zero_nop(blend->rts[rt].equation);
|
||||
pan_blend_alpha_zero_nop(blend->rts[rt].equation);
|
||||
cfg.internal.fixed_function.alpha_one_store =
|
||||
pan_blend_alpha_one_store(blend->rts[rt].equation);
|
||||
pan_blend_alpha_one_store(blend->rts[rt].equation);
|
||||
}
|
||||
|
||||
/* If we want the conversion to work properly,
|
||||
|
|
@ -678,8 +681,7 @@ panvk_per_arch(emit_blend_constant)(const struct panvk_device *dev,
|
|||
|
||||
void
|
||||
panvk_per_arch(emit_dyn_fs_rsd)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_cmd_state *state,
|
||||
void *rsd)
|
||||
const struct panvk_cmd_state *state, void *rsd)
|
||||
{
|
||||
pan_pack(rsd, RENDERER_STATE, cfg) {
|
||||
if (pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS)) {
|
||||
|
|
@ -688,17 +690,21 @@ panvk_per_arch(emit_dyn_fs_rsd)(const struct panvk_pipeline *pipeline,
|
|||
cfg.depth_bias_clamp = state->rast.depth_bias.clamp;
|
||||
}
|
||||
|
||||
if (pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) {
|
||||
if (pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) {
|
||||
cfg.stencil_front.mask = state->zs.s_front.compare_mask;
|
||||
cfg.stencil_back.mask = state->zs.s_back.compare_mask;
|
||||
}
|
||||
|
||||
if (pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) {
|
||||
cfg.stencil_mask_misc.stencil_mask_front = state->zs.s_front.write_mask;
|
||||
if (pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) {
|
||||
cfg.stencil_mask_misc.stencil_mask_front =
|
||||
state->zs.s_front.write_mask;
|
||||
cfg.stencil_mask_misc.stencil_mask_back = state->zs.s_back.write_mask;
|
||||
}
|
||||
|
||||
if (pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) {
|
||||
if (pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) {
|
||||
cfg.stencil_front.reference_value = state->zs.s_front.ref;
|
||||
cfg.stencil_back.reference_value = state->zs.s_back.ref;
|
||||
}
|
||||
|
|
@ -716,13 +722,12 @@ panvk_per_arch(emit_base_fs_rsd)(const struct panvk_device *dev,
|
|||
if (pipeline->fs.required) {
|
||||
pan_shader_prepare_rsd(info, pipeline->fs.address, &cfg);
|
||||
|
||||
uint8_t rt_written = pipeline->fs.info.outputs_written >> FRAG_RESULT_DATA0;
|
||||
uint8_t rt_written =
|
||||
pipeline->fs.info.outputs_written >> FRAG_RESULT_DATA0;
|
||||
uint8_t rt_mask = pipeline->fs.rt_mask;
|
||||
cfg.properties.allow_forward_pixel_to_kill =
|
||||
pipeline->fs.info.fs.can_fpk &&
|
||||
!(rt_mask & ~rt_written) &&
|
||||
!pipeline->ms.alpha_to_coverage &&
|
||||
!pipeline->blend.reads_dest;
|
||||
pipeline->fs.info.fs.can_fpk && !(rt_mask & ~rt_written) &&
|
||||
!pipeline->ms.alpha_to_coverage && !pipeline->blend.reads_dest;
|
||||
|
||||
bool writes_zs = pipeline->zs.z_write || pipeline->zs.s_test;
|
||||
bool zs_always_passes = !pipeline->zs.z_test && !pipeline->zs.s_test;
|
||||
|
|
@ -750,34 +755,45 @@ panvk_per_arch(emit_base_fs_rsd)(const struct panvk_device *dev,
|
|||
pipeline->zs.z_test ? pipeline->zs.z_compare_func : MALI_FUNC_ALWAYS;
|
||||
|
||||
cfg.multisample_misc.depth_write_mask = pipeline->zs.z_write;
|
||||
cfg.multisample_misc.fixed_function_near_discard = !pipeline->rast.clamp_depth;
|
||||
cfg.multisample_misc.fixed_function_far_discard = !pipeline->rast.clamp_depth;
|
||||
cfg.multisample_misc.fixed_function_near_discard =
|
||||
!pipeline->rast.clamp_depth;
|
||||
cfg.multisample_misc.fixed_function_far_discard =
|
||||
!pipeline->rast.clamp_depth;
|
||||
cfg.multisample_misc.shader_depth_range_fixed = true;
|
||||
|
||||
cfg.stencil_mask_misc.stencil_enable = pipeline->zs.s_test;
|
||||
cfg.stencil_mask_misc.alpha_to_coverage = pipeline->ms.alpha_to_coverage;
|
||||
cfg.stencil_mask_misc.alpha_test_compare_function = MALI_FUNC_ALWAYS;
|
||||
cfg.stencil_mask_misc.front_facing_depth_bias = pipeline->rast.depth_bias.enable;
|
||||
cfg.stencil_mask_misc.back_facing_depth_bias = pipeline->rast.depth_bias.enable;
|
||||
cfg.stencil_mask_misc.single_sampled_lines = pipeline->ms.rast_samples <= 1;
|
||||
cfg.stencil_mask_misc.front_facing_depth_bias =
|
||||
pipeline->rast.depth_bias.enable;
|
||||
cfg.stencil_mask_misc.back_facing_depth_bias =
|
||||
pipeline->rast.depth_bias.enable;
|
||||
cfg.stencil_mask_misc.single_sampled_lines =
|
||||
pipeline->ms.rast_samples <= 1;
|
||||
|
||||
if (!(pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS))) {
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_DEPTH_BIAS))) {
|
||||
cfg.depth_units = pipeline->rast.depth_bias.constant_factor * 2.0f;
|
||||
cfg.depth_factor = pipeline->rast.depth_bias.slope_factor;
|
||||
cfg.depth_bias_clamp = pipeline->rast.depth_bias.clamp;
|
||||
}
|
||||
|
||||
if (!(pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK))) {
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK))) {
|
||||
cfg.stencil_front.mask = pipeline->zs.s_front.compare_mask;
|
||||
cfg.stencil_back.mask = pipeline->zs.s_back.compare_mask;
|
||||
}
|
||||
|
||||
if (!(pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK))) {
|
||||
cfg.stencil_mask_misc.stencil_mask_front = pipeline->zs.s_front.write_mask;
|
||||
cfg.stencil_mask_misc.stencil_mask_back = pipeline->zs.s_back.write_mask;
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK))) {
|
||||
cfg.stencil_mask_misc.stencil_mask_front =
|
||||
pipeline->zs.s_front.write_mask;
|
||||
cfg.stencil_mask_misc.stencil_mask_back =
|
||||
pipeline->zs.s_back.write_mask;
|
||||
}
|
||||
|
||||
if (!(pipeline->dynamic_state_mask & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE))) {
|
||||
if (!(pipeline->dynamic_state_mask &
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE))) {
|
||||
cfg.stencil_front.reference_value = pipeline->zs.s_front.ref;
|
||||
cfg.stencil_back.reference_value = pipeline->zs.s_back.ref;
|
||||
}
|
||||
|
|
@ -796,8 +812,7 @@ panvk_per_arch(emit_base_fs_rsd)(const struct panvk_device *dev,
|
|||
void
|
||||
panvk_per_arch(emit_non_fs_rsd)(const struct panvk_device *dev,
|
||||
const struct pan_shader_info *shader_info,
|
||||
mali_ptr shader_ptr,
|
||||
void *rsd)
|
||||
mali_ptr shader_ptr, void *rsd)
|
||||
{
|
||||
assert(shader_info->stage != MESA_SHADER_FRAGMENT);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,100 +29,80 @@
|
|||
#error "no arch"
|
||||
#endif
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "compiler/shader_enums.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
void panvk_per_arch(emit_varying)(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage, unsigned idx,
|
||||
void *attrib);
|
||||
|
||||
void panvk_per_arch(emit_varyings)(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage, void *descs);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_varying)(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage, unsigned idx,
|
||||
void *attrib);
|
||||
panvk_per_arch(emit_varying_bufs)(const struct panvk_varyings_info *varyings,
|
||||
void *descs);
|
||||
|
||||
void panvk_per_arch(emit_attrib_bufs)(const struct panvk_attribs_info *info,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *descs);
|
||||
|
||||
void panvk_per_arch(emit_attribs)(const struct panvk_device *dev,
|
||||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_attribs_info *attribs,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count, void *descs);
|
||||
|
||||
void panvk_per_arch(emit_ubo)(mali_ptr address, size_t size, void *desc);
|
||||
|
||||
void panvk_per_arch(emit_ubos)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_descriptor_state *state,
|
||||
void *descs);
|
||||
|
||||
void panvk_per_arch(emit_sampler)(const VkSamplerCreateInfo *pCreateInfo,
|
||||
void *desc);
|
||||
|
||||
void panvk_per_arch(emit_vertex_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_varyings)(const struct panvk_device *dev,
|
||||
const struct panvk_varyings_info *varyings,
|
||||
gl_shader_stage stage,
|
||||
void *descs);
|
||||
panvk_per_arch(emit_compute_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_dispatch_info *dispatch,
|
||||
void *job);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_varying_bufs)(const struct panvk_varyings_info *varyings,
|
||||
void *descs);
|
||||
void panvk_per_arch(emit_tiler_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_attrib_bufs)(const struct panvk_attribs_info *info,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *descs);
|
||||
void panvk_per_arch(emit_viewport)(const VkViewport *viewport,
|
||||
const VkRect2D *scissor, void *vpd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_attribs)(const struct panvk_device *dev,
|
||||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_attribs_info *attribs,
|
||||
const struct panvk_attrib_buf *bufs,
|
||||
unsigned buf_count,
|
||||
void *descs);
|
||||
void panvk_per_arch(emit_blend)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
unsigned rt, void *bd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_ubo)(mali_ptr address, size_t size, void *desc);
|
||||
void panvk_per_arch(emit_blend_constant)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
unsigned rt, const float *constants,
|
||||
void *bd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_ubos)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_descriptor_state *state,
|
||||
void *descs);
|
||||
void panvk_per_arch(emit_dyn_fs_rsd)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_cmd_state *state,
|
||||
void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_sampler)(const VkSamplerCreateInfo *pCreateInfo,
|
||||
void *desc);
|
||||
void panvk_per_arch(emit_base_fs_rsd)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_vertex_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job);
|
||||
void panvk_per_arch(emit_non_fs_rsd)(const struct panvk_device *dev,
|
||||
const struct pan_shader_info *shader_info,
|
||||
mali_ptr shader_ptr, void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_compute_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_dispatch_info *dispatch,
|
||||
void *job);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_tiler_job)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_draw_info *draw,
|
||||
void *job);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_viewport)(const VkViewport *viewport,
|
||||
const VkRect2D *scissor,
|
||||
void *vpd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_blend)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
unsigned rt, void *bd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_blend_constant)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
unsigned rt, const float *constants,
|
||||
void *bd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_dyn_fs_rsd)(const struct panvk_pipeline *pipeline,
|
||||
const struct panvk_cmd_state *state,
|
||||
void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_base_fs_rsd)(const struct panvk_device *dev,
|
||||
const struct panvk_pipeline *pipeline,
|
||||
void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_non_fs_rsd)(const struct panvk_device *dev,
|
||||
const struct pan_shader_info *shader_info,
|
||||
mali_ptr shader_ptr,
|
||||
void *rsd);
|
||||
|
||||
void
|
||||
panvk_per_arch(emit_tiler_context)(const struct panvk_device *dev,
|
||||
unsigned width, unsigned height,
|
||||
const struct panfrost_ptr *descs);
|
||||
void panvk_per_arch(emit_tiler_context)(const struct panvk_device *dev,
|
||||
unsigned width, unsigned height,
|
||||
const struct panfrost_ptr *descs);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "vk_descriptors.h"
|
||||
#include "vk_descriptor_update_template.h"
|
||||
#include "vk_descriptors.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include "pan_bo.h"
|
||||
|
|
@ -82,10 +82,9 @@ panvk_fill_image_desc(struct panvk_image_desc *desc,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
||||
const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDescriptorSetLayout *pSetLayout)
|
||||
panvk_per_arch(CreateDescriptorSetLayout)(
|
||||
VkDevice _device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
struct panvk_descriptor_set_layout *set_layout;
|
||||
|
|
@ -94,10 +93,8 @@ panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
|||
VkResult result;
|
||||
|
||||
if (pCreateInfo->bindingCount) {
|
||||
result =
|
||||
vk_create_sorted_bindings(pCreateInfo->pBindings,
|
||||
pCreateInfo->bindingCount,
|
||||
&bindings);
|
||||
result = vk_create_sorted_bindings(pCreateInfo->pBindings,
|
||||
pCreateInfo->bindingCount, &bindings);
|
||||
if (result != VK_SUCCESS)
|
||||
return vk_error(device, result);
|
||||
|
||||
|
|
@ -110,10 +107,10 @@ panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
|||
num_immutable_samplers += bindings[i].descriptorCount;
|
||||
}
|
||||
|
||||
size_t size = sizeof(*set_layout) +
|
||||
(sizeof(struct panvk_descriptor_set_binding_layout) *
|
||||
num_bindings) +
|
||||
(sizeof(struct panvk_sampler *) * num_immutable_samplers);
|
||||
size_t size =
|
||||
sizeof(*set_layout) +
|
||||
(sizeof(struct panvk_descriptor_set_binding_layout) * num_bindings) +
|
||||
(sizeof(struct panvk_sampler *) * num_immutable_samplers);
|
||||
set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size);
|
||||
if (!set_layout) {
|
||||
result = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
|
@ -122,7 +119,8 @@ panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
|||
|
||||
struct panvk_sampler **immutable_samplers =
|
||||
(struct panvk_sampler **)((uint8_t *)set_layout + sizeof(*set_layout) +
|
||||
(sizeof(struct panvk_descriptor_set_binding_layout) *
|
||||
(sizeof(
|
||||
struct panvk_descriptor_set_binding_layout) *
|
||||
num_bindings));
|
||||
|
||||
set_layout->binding_count = num_bindings;
|
||||
|
|
@ -144,7 +142,8 @@ panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
|||
binding_layout->immutable_samplers = immutable_samplers;
|
||||
immutable_samplers += binding_layout->array_size;
|
||||
for (unsigned j = 0; j < binding_layout->array_size; j++) {
|
||||
VK_FROM_HANDLE(panvk_sampler, sampler, binding->pImmutableSamplers[j]);
|
||||
VK_FROM_HANDLE(panvk_sampler, sampler,
|
||||
binding->pImmutableSamplers[j]);
|
||||
binding_layout->immutable_samplers[j] = sampler;
|
||||
}
|
||||
}
|
||||
|
|
@ -203,8 +202,8 @@ panvk_per_arch(CreateDescriptorSetLayout)(VkDevice _device,
|
|||
|
||||
desc_ubo_size = ALIGN_POT(desc_ubo_size, PANVK_DESCRIPTOR_ALIGN);
|
||||
binding_layout->desc_ubo_offset = desc_ubo_size;
|
||||
desc_ubo_size += binding_layout->desc_ubo_stride *
|
||||
binding_layout->array_size;
|
||||
desc_ubo_size +=
|
||||
binding_layout->desc_ubo_stride * binding_layout->array_size;
|
||||
}
|
||||
|
||||
set_layout->desc_ubo_size = desc_ubo_size;
|
||||
|
|
@ -227,23 +226,22 @@ err_free_bindings:
|
|||
return vk_error(device, result);
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_write_sampler_desc_raw(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
struct panvk_sampler *sampler);
|
||||
static void panvk_write_sampler_desc_raw(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
struct panvk_sampler *sampler);
|
||||
|
||||
static VkResult
|
||||
panvk_per_arch(descriptor_set_create)(struct panvk_device *device,
|
||||
struct panvk_descriptor_pool *pool,
|
||||
const struct panvk_descriptor_set_layout *layout,
|
||||
struct panvk_descriptor_set **out_set)
|
||||
panvk_per_arch(descriptor_set_create)(
|
||||
struct panvk_device *device, struct panvk_descriptor_pool *pool,
|
||||
const struct panvk_descriptor_set_layout *layout,
|
||||
struct panvk_descriptor_set **out_set)
|
||||
{
|
||||
struct panvk_descriptor_set *set;
|
||||
|
||||
/* TODO: Allocate from the pool! */
|
||||
set = vk_object_zalloc(&device->vk, NULL,
|
||||
sizeof(struct panvk_descriptor_set),
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
set =
|
||||
vk_object_zalloc(&device->vk, NULL, sizeof(struct panvk_descriptor_set),
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
@ -259,24 +257,24 @@ panvk_per_arch(descriptor_set_create)(struct panvk_device *device,
|
|||
|
||||
if (layout->num_dyn_ubos) {
|
||||
set->dyn_ubos = vk_zalloc(&device->vk.alloc,
|
||||
sizeof(*set->dyn_ubos) * layout->num_dyn_ubos, 8,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
sizeof(*set->dyn_ubos) * layout->num_dyn_ubos,
|
||||
8, VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set->dyn_ubos)
|
||||
goto err_free_set;
|
||||
}
|
||||
|
||||
if (layout->num_dyn_ssbos) {
|
||||
set->dyn_ssbos = vk_zalloc(&device->vk.alloc,
|
||||
sizeof(*set->dyn_ssbos) * layout->num_dyn_ssbos, 8,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
set->dyn_ssbos = vk_zalloc(
|
||||
&device->vk.alloc, sizeof(*set->dyn_ssbos) * layout->num_dyn_ssbos, 8,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set->dyn_ssbos)
|
||||
goto err_free_set;
|
||||
}
|
||||
|
||||
if (layout->num_samplers) {
|
||||
set->samplers = vk_zalloc(&device->vk.alloc,
|
||||
pan_size(SAMPLER) * layout->num_samplers, 8,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
set->samplers =
|
||||
vk_zalloc(&device->vk.alloc, pan_size(SAMPLER) * layout->num_samplers,
|
||||
8, VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set->samplers)
|
||||
goto err_free_set;
|
||||
}
|
||||
|
|
@ -291,31 +289,28 @@ panvk_per_arch(descriptor_set_create)(struct panvk_device *device,
|
|||
|
||||
if (layout->num_imgs) {
|
||||
set->img_fmts =
|
||||
vk_zalloc(&device->vk.alloc,
|
||||
sizeof(*set->img_fmts) * layout->num_imgs,
|
||||
vk_zalloc(&device->vk.alloc, sizeof(*set->img_fmts) * layout->num_imgs,
|
||||
8, VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set->img_fmts)
|
||||
goto err_free_set;
|
||||
|
||||
set->img_attrib_bufs =
|
||||
vk_zalloc(&device->vk.alloc,
|
||||
pan_size(ATTRIBUTE_BUFFER) * 2 * layout->num_imgs,
|
||||
8, VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
set->img_attrib_bufs = vk_zalloc(
|
||||
&device->vk.alloc, pan_size(ATTRIBUTE_BUFFER) * 2 * layout->num_imgs,
|
||||
8, VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
if (!set->img_attrib_bufs)
|
||||
goto err_free_set;
|
||||
}
|
||||
|
||||
if (layout->desc_ubo_size) {
|
||||
set->desc_bo = panfrost_bo_create(&device->physical_device->pdev,
|
||||
layout->desc_ubo_size,
|
||||
0, "Descriptor set");
|
||||
set->desc_bo =
|
||||
panfrost_bo_create(&device->physical_device->pdev,
|
||||
layout->desc_ubo_size, 0, "Descriptor set");
|
||||
if (!set->desc_bo)
|
||||
goto err_free_set;
|
||||
|
||||
struct mali_uniform_buffer_packed *ubos = set->ubos;
|
||||
|
||||
panvk_per_arch(emit_ubo)(set->desc_bo->ptr.gpu,
|
||||
layout->desc_ubo_size,
|
||||
panvk_per_arch(emit_ubo)(set->desc_bo->ptr.gpu, layout->desc_ubo_size,
|
||||
&ubos[layout->desc_ubo_index]);
|
||||
}
|
||||
|
||||
|
|
@ -348,9 +343,9 @@ err_free_set:
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_per_arch(AllocateDescriptorSets)(VkDevice _device,
|
||||
const VkDescriptorSetAllocateInfo *pAllocateInfo,
|
||||
VkDescriptorSet *pDescriptorSets)
|
||||
panvk_per_arch(AllocateDescriptorSets)(
|
||||
VkDevice _device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
|
||||
VkDescriptorSet *pDescriptorSets)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_descriptor_pool, pool, pAllocateInfo->descriptorPool);
|
||||
|
|
@ -362,7 +357,8 @@ panvk_per_arch(AllocateDescriptorSets)(VkDevice _device,
|
|||
pAllocateInfo->pSetLayouts[i]);
|
||||
struct panvk_descriptor_set *set = NULL;
|
||||
|
||||
result = panvk_per_arch(descriptor_set_create)(device, pool, layout, &set);
|
||||
result =
|
||||
panvk_per_arch(descriptor_set_create)(device, pool, layout, &set);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_free_sets;
|
||||
|
||||
|
|
@ -372,28 +368,28 @@ panvk_per_arch(AllocateDescriptorSets)(VkDevice _device,
|
|||
return VK_SUCCESS;
|
||||
|
||||
err_free_sets:
|
||||
panvk_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool, i, pDescriptorSets);
|
||||
panvk_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool, i,
|
||||
pDescriptorSets);
|
||||
for (i = 0; i < pAllocateInfo->descriptorSetCount; i++)
|
||||
pDescriptorSets[i] = VK_NULL_HANDLE;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void *
|
||||
panvk_desc_ubo_data(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_desc_ubo_data(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
||||
return (char *)set->desc_bo->ptr.cpu +
|
||||
binding_layout->desc_ubo_offset +
|
||||
return (char *)set->desc_bo->ptr.cpu + binding_layout->desc_ubo_offset +
|
||||
elem * binding_layout->desc_ubo_stride;
|
||||
}
|
||||
|
||||
static struct mali_sampler_packed *
|
||||
panvk_sampler_desc(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_sampler_desc(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -404,19 +400,18 @@ panvk_sampler_desc(struct panvk_descriptor_set *set,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_write_sampler_desc_raw(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
struct panvk_sampler *sampler)
|
||||
panvk_write_sampler_desc_raw(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem, struct panvk_sampler *sampler)
|
||||
{
|
||||
memcpy(panvk_sampler_desc(set, binding, elem),
|
||||
&sampler->desc, sizeof(sampler->desc));
|
||||
memcpy(panvk_sampler_desc(set, binding, elem), &sampler->desc,
|
||||
sizeof(sampler->desc));
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_write_sampler_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkDescriptorImageInfo * const pImageInfo)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem,
|
||||
const VkDescriptorImageInfo *const pImageInfo)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -446,8 +441,8 @@ panvk_copy_sampler_desc(struct panvk_descriptor_set *dst_set,
|
|||
}
|
||||
|
||||
static struct mali_texture_packed *
|
||||
panvk_tex_desc(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_tex_desc(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -459,22 +454,21 @@ panvk_tex_desc(struct panvk_descriptor_set *set,
|
|||
|
||||
static void
|
||||
panvk_write_tex_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkDescriptorImageInfo * const pImageInfo)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem,
|
||||
const VkDescriptorImageInfo *const pImageInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_image_view, view, pImageInfo->imageView);
|
||||
|
||||
memcpy(panvk_tex_desc(set, binding, elem),
|
||||
view->descs.tex, pan_size(TEXTURE));
|
||||
memcpy(panvk_tex_desc(set, binding, elem), view->descs.tex,
|
||||
pan_size(TEXTURE));
|
||||
|
||||
panvk_fill_image_desc(panvk_desc_ubo_data(set, binding, elem), view);
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_copy_tex_desc(struct panvk_descriptor_set *dst_set,
|
||||
uint32_t dst_binding, uint32_t dst_elem,
|
||||
struct panvk_descriptor_set *src_set,
|
||||
panvk_copy_tex_desc(struct panvk_descriptor_set *dst_set, uint32_t dst_binding,
|
||||
uint32_t dst_elem, struct panvk_descriptor_set *src_set,
|
||||
uint32_t src_binding, uint32_t src_elem)
|
||||
{
|
||||
*panvk_tex_desc(dst_set, dst_binding, dst_elem) =
|
||||
|
|
@ -485,21 +479,19 @@ panvk_copy_tex_desc(struct panvk_descriptor_set *dst_set,
|
|||
|
||||
static void
|
||||
panvk_write_tex_buf_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkBufferView bufferView)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem, const VkBufferView bufferView)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_buffer_view, view, bufferView);
|
||||
|
||||
memcpy(panvk_tex_desc(set, binding, elem),
|
||||
view->descs.tex, pan_size(TEXTURE));
|
||||
memcpy(panvk_tex_desc(set, binding, elem), view->descs.tex,
|
||||
pan_size(TEXTURE));
|
||||
|
||||
panvk_fill_bview_desc(panvk_desc_ubo_data(set, binding, elem), view);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
panvk_img_idx(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_img_idx(struct panvk_descriptor_set *set, uint32_t binding, uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -508,8 +500,7 @@ panvk_img_idx(struct panvk_descriptor_set *set,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_write_img_desc(struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
panvk_write_img_desc(struct panvk_device *dev, struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkDescriptorImageInfo *pImageInfo)
|
||||
{
|
||||
|
|
@ -521,15 +512,15 @@ panvk_write_img_desc(struct panvk_device *dev,
|
|||
(pan_size(ATTRIBUTE_BUFFER) * 2 * img_idx);
|
||||
|
||||
set->img_fmts[img_idx] = pdev->formats[view->pview.format].hw;
|
||||
memcpy(attrib_buf, view->descs.img_attrib_buf, pan_size(ATTRIBUTE_BUFFER) * 2);
|
||||
memcpy(attrib_buf, view->descs.img_attrib_buf,
|
||||
pan_size(ATTRIBUTE_BUFFER) * 2);
|
||||
|
||||
panvk_fill_image_desc(panvk_desc_ubo_data(set, binding, elem), view);
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_copy_img_desc(struct panvk_descriptor_set *dst_set,
|
||||
uint32_t dst_binding, uint32_t dst_elem,
|
||||
struct panvk_descriptor_set *src_set,
|
||||
panvk_copy_img_desc(struct panvk_descriptor_set *dst_set, uint32_t dst_binding,
|
||||
uint32_t dst_elem, struct panvk_descriptor_set *src_set,
|
||||
uint32_t src_binding, uint32_t src_elem)
|
||||
{
|
||||
unsigned dst_img_idx = panvk_img_idx(dst_set, dst_binding, dst_elem);
|
||||
|
|
@ -548,9 +539,8 @@ panvk_copy_img_desc(struct panvk_descriptor_set *dst_set,
|
|||
|
||||
static void
|
||||
panvk_write_img_buf_desc(struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkBufferView bufferView)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem, const VkBufferView bufferView)
|
||||
{
|
||||
const struct panfrost_device *pdev = &dev->physical_device->pdev;
|
||||
VK_FROM_HANDLE(panvk_buffer_view, view, bufferView);
|
||||
|
|
@ -560,14 +550,15 @@ panvk_write_img_buf_desc(struct panvk_device *dev,
|
|||
(pan_size(ATTRIBUTE_BUFFER) * 2 * img_idx);
|
||||
|
||||
set->img_fmts[img_idx] = pdev->formats[view->fmt].hw;
|
||||
memcpy(attrib_buf, view->descs.img_attrib_buf, pan_size(ATTRIBUTE_BUFFER) * 2);
|
||||
memcpy(attrib_buf, view->descs.img_attrib_buf,
|
||||
pan_size(ATTRIBUTE_BUFFER) * 2);
|
||||
|
||||
panvk_fill_bview_desc(panvk_desc_ubo_data(set, binding, elem), view);
|
||||
}
|
||||
|
||||
static struct mali_uniform_buffer_packed *
|
||||
panvk_ubo_desc(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_ubo_desc(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -579,23 +570,21 @@ panvk_ubo_desc(struct panvk_descriptor_set *set,
|
|||
|
||||
static void
|
||||
panvk_write_ubo_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkDescriptorBufferInfo *pBufferInfo)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem, const VkDescriptorBufferInfo *pBufferInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_buffer, buffer, pBufferInfo->buffer);
|
||||
|
||||
mali_ptr ptr = panvk_buffer_gpu_ptr(buffer, pBufferInfo->offset);
|
||||
size_t size = panvk_buffer_range(buffer, pBufferInfo->offset,
|
||||
pBufferInfo->range);
|
||||
size_t size =
|
||||
panvk_buffer_range(buffer, pBufferInfo->offset, pBufferInfo->range);
|
||||
|
||||
panvk_per_arch(emit_ubo)(ptr, size, panvk_ubo_desc(set, binding, elem));
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_copy_ubo_desc(struct panvk_descriptor_set *dst_set,
|
||||
uint32_t dst_binding, uint32_t dst_elem,
|
||||
struct panvk_descriptor_set *src_set,
|
||||
panvk_copy_ubo_desc(struct panvk_descriptor_set *dst_set, uint32_t dst_binding,
|
||||
uint32_t dst_elem, struct panvk_descriptor_set *src_set,
|
||||
uint32_t src_binding, uint32_t src_elem)
|
||||
{
|
||||
*panvk_ubo_desc(dst_set, dst_binding, dst_elem) =
|
||||
|
|
@ -603,8 +592,8 @@ panvk_copy_ubo_desc(struct panvk_descriptor_set *dst_set,
|
|||
}
|
||||
|
||||
static struct panvk_buffer_desc *
|
||||
panvk_dyn_ubo_desc(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_dyn_ubo_desc(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -614,13 +603,13 @@ panvk_dyn_ubo_desc(struct panvk_descriptor_set *set,
|
|||
|
||||
static void
|
||||
panvk_write_dyn_ubo_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem,
|
||||
const VkDescriptorBufferInfo *pBufferInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_buffer, buffer, pBufferInfo->buffer);
|
||||
|
||||
*panvk_dyn_ubo_desc(set, binding, elem) = (struct panvk_buffer_desc) {
|
||||
*panvk_dyn_ubo_desc(set, binding, elem) = (struct panvk_buffer_desc){
|
||||
.buffer = buffer,
|
||||
.offset = pBufferInfo->offset,
|
||||
.size = pBufferInfo->range,
|
||||
|
|
@ -639,32 +628,30 @@ panvk_copy_dyn_ubo_desc(struct panvk_descriptor_set *dst_set,
|
|||
|
||||
static void
|
||||
panvk_write_ssbo_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
const VkDescriptorBufferInfo *pBufferInfo)
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem, const VkDescriptorBufferInfo *pBufferInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_buffer, buffer, pBufferInfo->buffer);
|
||||
|
||||
struct panvk_ssbo_addr *desc = panvk_desc_ubo_data(set, binding, elem);
|
||||
*desc = (struct panvk_ssbo_addr) {
|
||||
*desc = (struct panvk_ssbo_addr){
|
||||
.base_addr = panvk_buffer_gpu_ptr(buffer, pBufferInfo->offset),
|
||||
.size = panvk_buffer_range(buffer, pBufferInfo->offset,
|
||||
pBufferInfo->range),
|
||||
.size =
|
||||
panvk_buffer_range(buffer, pBufferInfo->offset, pBufferInfo->range),
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_copy_ssbo_desc(struct panvk_descriptor_set *dst_set,
|
||||
uint32_t dst_binding, uint32_t dst_elem,
|
||||
struct panvk_descriptor_set *src_set,
|
||||
panvk_copy_ssbo_desc(struct panvk_descriptor_set *dst_set, uint32_t dst_binding,
|
||||
uint32_t dst_elem, struct panvk_descriptor_set *src_set,
|
||||
uint32_t src_binding, uint32_t src_elem)
|
||||
{
|
||||
/* Descriptor UBO data gets copied automatically */
|
||||
}
|
||||
|
||||
static struct panvk_buffer_desc *
|
||||
panvk_dyn_ssbo_desc(struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem)
|
||||
panvk_dyn_ssbo_desc(struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->bindings[binding];
|
||||
|
|
@ -674,13 +661,13 @@ panvk_dyn_ssbo_desc(struct panvk_descriptor_set *set,
|
|||
|
||||
static void
|
||||
panvk_write_dyn_ssbo_desc(UNUSED struct panvk_device *dev,
|
||||
struct panvk_descriptor_set *set,
|
||||
uint32_t binding, uint32_t elem,
|
||||
struct panvk_descriptor_set *set, uint32_t binding,
|
||||
uint32_t elem,
|
||||
const VkDescriptorBufferInfo *pBufferInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_buffer, buffer, pBufferInfo->buffer);
|
||||
|
||||
*panvk_dyn_ssbo_desc(set, binding, elem) = (struct panvk_buffer_desc) {
|
||||
*panvk_dyn_ssbo_desc(set, binding, elem) = (struct panvk_buffer_desc){
|
||||
.buffer = buffer,
|
||||
.offset = pBufferInfo->offset,
|
||||
.size = pBufferInfo->range,
|
||||
|
|
@ -698,11 +685,10 @@ panvk_copy_dyn_ssbo_desc(struct panvk_descriptor_set *dst_set,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
||||
uint32_t descriptorWriteCount,
|
||||
const VkWriteDescriptorSet *pDescriptorWrites,
|
||||
uint32_t descriptorCopyCount,
|
||||
const VkCopyDescriptorSet *pDescriptorCopies)
|
||||
panvk_per_arch(UpdateDescriptorSets)(
|
||||
VkDevice _device, uint32_t descriptorWriteCount,
|
||||
const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
|
||||
const VkCopyDescriptorSet *pDescriptorCopies)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, dev, _device);
|
||||
|
||||
|
|
@ -713,8 +699,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
switch (write->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_sampler_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_sampler_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pImageInfo[j]);
|
||||
}
|
||||
|
|
@ -722,12 +707,10 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_sampler_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_sampler_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pImageInfo[j]);
|
||||
panvk_write_tex_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_tex_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pImageInfo[j]);
|
||||
}
|
||||
|
|
@ -735,8 +718,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_tex_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_tex_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pImageInfo[j]);
|
||||
}
|
||||
|
|
@ -745,8 +727,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_img_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_img_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pImageInfo[j]);
|
||||
}
|
||||
|
|
@ -754,8 +735,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_tex_buf_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_tex_buf_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
write->pTexelBufferView[j]);
|
||||
}
|
||||
|
|
@ -763,8 +743,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_img_buf_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_img_buf_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
write->pTexelBufferView[j]);
|
||||
}
|
||||
|
|
@ -772,8 +751,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_ubo_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_ubo_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pBufferInfo[j]);
|
||||
}
|
||||
|
|
@ -781,8 +759,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_dyn_ubo_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_dyn_ubo_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pBufferInfo[j]);
|
||||
}
|
||||
|
|
@ -790,8 +767,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_ssbo_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_ssbo_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pBufferInfo[j]);
|
||||
}
|
||||
|
|
@ -799,8 +775,7 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
panvk_write_dyn_ssbo_desc(dev, set,
|
||||
write->dstBinding,
|
||||
panvk_write_dyn_ssbo_desc(dev, set, write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
&write->pBufferInfo[j]);
|
||||
}
|
||||
|
|
@ -838,23 +813,20 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
switch (src_binding_layout->type) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_sampler_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
panvk_copy_sampler_desc(
|
||||
dst_set, copy->dstBinding, copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_sampler_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
panvk_copy_sampler_desc(
|
||||
dst_set, copy->dstBinding, copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
panvk_copy_tex_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -862,9 +834,8 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_tex_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -873,45 +844,40 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_img_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_ubo_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_dyn_ubo_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
panvk_copy_dyn_ubo_desc(
|
||||
dst_set, copy->dstBinding, copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_ssbo_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
for (uint32_t j = 0; j < copy->descriptorCount; j++) {
|
||||
panvk_copy_dyn_ssbo_desc(dst_set, copy->dstBinding,
|
||||
copy->dstArrayElement + j,
|
||||
src_set, copy->srcBinding,
|
||||
copy->srcArrayElement + j);
|
||||
panvk_copy_dyn_ssbo_desc(
|
||||
dst_set, copy->dstBinding, copy->dstArrayElement + j, src_set,
|
||||
copy->srcBinding, copy->srcArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -922,10 +888,9 @@ panvk_per_arch(UpdateDescriptorSets)(VkDevice _device,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
||||
VkDescriptorSet descriptorSet,
|
||||
VkDescriptorUpdateTemplate descriptorUpdateTemplate,
|
||||
const void *data)
|
||||
panvk_per_arch(UpdateDescriptorSetWithTemplate)(
|
||||
VkDevice _device, VkDescriptorSet descriptorSet,
|
||||
VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void *data)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, dev, _device);
|
||||
VK_FROM_HANDLE(panvk_descriptor_set, set, descriptorSet);
|
||||
|
|
@ -935,8 +900,7 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const struct panvk_descriptor_set_layout *layout = set->layout;
|
||||
|
||||
for (uint32_t i = 0; i < template->entry_count; i++) {
|
||||
const struct vk_descriptor_template_entry *entry =
|
||||
&template->entries[i];
|
||||
const struct vk_descriptor_template_entry *entry = &template->entries[i];
|
||||
const struct panvk_descriptor_set_binding_layout *binding_layout =
|
||||
&layout->bindings[entry->binding];
|
||||
|
||||
|
|
@ -952,19 +916,15 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
entry->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) &&
|
||||
!binding_layout->immutable_samplers) {
|
||||
|
||||
panvk_write_sampler_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_sampler_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
|
||||
if (entry->type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ||
|
||||
entry->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
|
||||
|
||||
panvk_write_tex_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_tex_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -975,34 +935,26 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const VkDescriptorImageInfo *info =
|
||||
data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_img_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_img_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
for (unsigned j = 0; j < entry->array_count; j++) {
|
||||
const VkBufferView *view =
|
||||
data + entry->offset + j * entry->stride;
|
||||
const VkBufferView *view = data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_tex_buf_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
*view);
|
||||
panvk_write_tex_buf_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, *view);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
for (unsigned j = 0; j < entry->array_count; j++) {
|
||||
const VkBufferView *view =
|
||||
data + entry->offset + j * entry->stride;
|
||||
const VkBufferView *view = data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_img_buf_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
*view);
|
||||
panvk_write_img_buf_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, *view);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1011,10 +963,8 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const VkDescriptorBufferInfo *info =
|
||||
data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_ubo_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_ubo_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1023,10 +973,8 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const VkDescriptorBufferInfo *info =
|
||||
data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_dyn_ubo_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_dyn_ubo_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1035,10 +983,8 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const VkDescriptorBufferInfo *info =
|
||||
data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_ssbo_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_ssbo_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1047,10 +993,8 @@ panvk_per_arch(UpdateDescriptorSetWithTemplate)(VkDevice _device,
|
|||
const VkDescriptorBufferInfo *info =
|
||||
data + entry->offset + j * entry->stride;
|
||||
|
||||
panvk_write_dyn_ssbo_desc(dev, set,
|
||||
entry->binding,
|
||||
entry->array_element + j,
|
||||
info);
|
||||
panvk_write_dyn_ssbo_desc(dev, set, entry->binding,
|
||||
entry->array_element + j, info);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -30,16 +30,14 @@
|
|||
|
||||
#include "decode.h"
|
||||
|
||||
#include "panvk_private.h"
|
||||
#include "panvk_cs.h"
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "vk_drm_syncobj.h"
|
||||
|
||||
static void
|
||||
panvk_queue_submit_batch(struct panvk_queue *queue,
|
||||
struct panvk_batch *batch,
|
||||
uint32_t *bos, unsigned nr_bos,
|
||||
uint32_t *in_fences,
|
||||
panvk_queue_submit_batch(struct panvk_queue *queue, struct panvk_batch *batch,
|
||||
uint32_t *bos, unsigned nr_bos, uint32_t *in_fences,
|
||||
unsigned nr_in_fences)
|
||||
{
|
||||
const struct panvk_device *dev = queue->device;
|
||||
|
|
@ -73,7 +71,8 @@ panvk_queue_submit_batch(struct panvk_queue *queue,
|
|||
assert(!ret);
|
||||
|
||||
if (debug & (PANVK_DEBUG_TRACE | PANVK_DEBUG_SYNC)) {
|
||||
ret = drmSyncobjWait(pdev->fd, &submit.out_sync, 1, INT64_MAX, 0, NULL);
|
||||
ret =
|
||||
drmSyncobjWait(pdev->fd, &submit.out_sync, 1, INT64_MAX, 0, NULL);
|
||||
assert(!ret);
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +103,8 @@ panvk_queue_submit_batch(struct panvk_queue *queue,
|
|||
ret = drmIoctl(pdev->fd, DRM_IOCTL_PANFROST_SUBMIT, &submit);
|
||||
assert(!ret);
|
||||
if (debug & (PANVK_DEBUG_TRACE | PANVK_DEBUG_SYNC)) {
|
||||
ret = drmSyncobjWait(pdev->fd, &submit.out_sync, 1, INT64_MAX, 0, NULL);
|
||||
ret =
|
||||
drmSyncobjWait(pdev->fd, &submit.out_sync, 1, INT64_MAX, 0, NULL);
|
||||
assert(!ret);
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +145,8 @@ panvk_queue_transfer_sync(struct panvk_queue *queue, uint32_t syncobj)
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_add_wait_event_syncobjs(struct panvk_batch *batch, uint32_t *in_fences, unsigned *nr_in_fences)
|
||||
panvk_add_wait_event_syncobjs(struct panvk_batch *batch, uint32_t *in_fences,
|
||||
unsigned *nr_in_fences)
|
||||
{
|
||||
util_dynarray_foreach(&batch->event_ops, struct panvk_event_op, op) {
|
||||
switch (op->type) {
|
||||
|
|
@ -165,7 +166,8 @@ panvk_add_wait_event_syncobjs(struct panvk_batch *batch, uint32_t *in_fences, un
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_signal_event_syncobjs(struct panvk_queue *queue, struct panvk_batch *batch)
|
||||
panvk_signal_event_syncobjs(struct panvk_queue *queue,
|
||||
struct panvk_batch *batch)
|
||||
{
|
||||
const struct panfrost_device *pdev = &queue->device->physical_device->pdev;
|
||||
|
||||
|
|
@ -179,9 +181,8 @@ panvk_signal_event_syncobjs(struct panvk_queue *queue, struct panvk_batch *batch
|
|||
struct panvk_event *event = op->event;
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t) (uintptr_t) &event->syncobj,
|
||||
.count_handles = 1
|
||||
};
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
int ret = drmIoctl(pdev->fd, DRM_IOCTL_SYNCOBJ_RESET, &objs);
|
||||
assert(!ret);
|
||||
|
|
@ -200,8 +201,7 @@ VkResult
|
|||
panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
||||
struct vk_queue_submit *submit)
|
||||
{
|
||||
struct panvk_queue *queue =
|
||||
container_of(vk_queue, struct panvk_queue, vk);
|
||||
struct panvk_queue *queue = container_of(vk_queue, struct panvk_queue, vk);
|
||||
const struct panfrost_device *pdev = &queue->device->physical_device->pdev;
|
||||
|
||||
unsigned nr_semaphores = submit->wait_count + 1;
|
||||
|
|
@ -227,8 +227,7 @@ panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
|||
panvk_pool_num_bos(&cmdbuf->varying_pool) +
|
||||
panvk_pool_num_bos(&cmdbuf->tls_pool) +
|
||||
(batch->fb.info ? batch->fb.info->attachment_count : 0) +
|
||||
(batch->blit.src ? 1 : 0) +
|
||||
(batch->blit.dst ? 1 : 0) +
|
||||
(batch->blit.src ? 1 : 0) + (batch->blit.dst ? 1 : 0) +
|
||||
(batch->scoreboard.first_tiler ? 1 : 0) + 1;
|
||||
unsigned bo_idx = 0;
|
||||
uint32_t bos[nr_bos];
|
||||
|
|
@ -244,7 +243,8 @@ panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
|||
|
||||
if (batch->fb.info) {
|
||||
for (unsigned i = 0; i < batch->fb.info->attachment_count; i++) {
|
||||
bos[bo_idx++] = batch->fb.info->attachments[i].iview->pview.image->data.bo->gem_handle;
|
||||
bos[bo_idx++] = batch->fb.info->attachments[i]
|
||||
.iview->pview.image->data.bo->gem_handle;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
|||
|
||||
/* Merge identical BO entries. */
|
||||
for (unsigned x = 0; x < nr_bos; x++) {
|
||||
for (unsigned y = x + 1; y < nr_bos; ) {
|
||||
for (unsigned y = x + 1; y < nr_bos;) {
|
||||
if (bos[x] == bos[y])
|
||||
bos[y] = bos[--nr_bos];
|
||||
else
|
||||
|
|
@ -271,16 +271,16 @@ panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
|||
}
|
||||
|
||||
unsigned nr_in_fences = 0;
|
||||
unsigned max_wait_event_syncobjs =
|
||||
util_dynarray_num_elements(&batch->event_ops,
|
||||
struct panvk_event_op);
|
||||
unsigned max_wait_event_syncobjs = util_dynarray_num_elements(
|
||||
&batch->event_ops, struct panvk_event_op);
|
||||
uint32_t in_fences[nr_semaphores + max_wait_event_syncobjs];
|
||||
memcpy(in_fences, semaphores, nr_semaphores * sizeof(*in_fences));
|
||||
nr_in_fences += nr_semaphores;
|
||||
|
||||
panvk_add_wait_event_syncobjs(batch, in_fences, &nr_in_fences);
|
||||
|
||||
panvk_queue_submit_batch(queue, batch, bos, nr_bos, in_fences, nr_in_fences);
|
||||
panvk_queue_submit_batch(queue, batch, bos, nr_bos, in_fences,
|
||||
nr_in_fences);
|
||||
|
||||
panvk_signal_event_syncobjs(queue, batch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,5 @@
|
|||
#error "no arch"
|
||||
#endif
|
||||
|
||||
VkResult
|
||||
panvk_per_arch(queue_submit)(struct vk_queue *queue,
|
||||
struct vk_queue_submit *submit);
|
||||
VkResult panvk_per_arch(queue_submit)(struct vk_queue *queue,
|
||||
struct vk_queue_submit *submit);
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@
|
|||
#include "genxml/gen_macros.h"
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_object.h"
|
||||
#include "vk_util.h"
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
|
||||
static enum mali_texture_dimension
|
||||
panvk_view_type_to_mali_tex_dim(VkImageViewType type)
|
||||
|
|
@ -57,8 +57,7 @@ panvk_view_type_to_mali_tex_dim(VkImageViewType type)
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_convert_swizzle(const VkComponentMapping *in,
|
||||
unsigned char *out)
|
||||
panvk_convert_swizzle(const VkComponentMapping *in, unsigned char *out)
|
||||
{
|
||||
const VkComponentSwizzle *comp = &in->r;
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
|
|
@ -97,22 +96,20 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
|
|||
VK_FROM_HANDLE(panvk_image, image, pCreateInfo->image);
|
||||
struct panvk_image_view *view;
|
||||
|
||||
view = vk_image_view_create(&device->vk, false, pCreateInfo,
|
||||
pAllocator, sizeof(*view));
|
||||
view = vk_image_view_create(&device->vk, false, pCreateInfo, pAllocator,
|
||||
sizeof(*view));
|
||||
if (view == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
view->pview = (struct pan_image_view) {
|
||||
view->pview = (struct pan_image_view){
|
||||
.image = &image->pimage,
|
||||
.format = vk_format_to_pipe_format(view->vk.view_format),
|
||||
.dim = panvk_view_type_to_mali_tex_dim(view->vk.view_type),
|
||||
.nr_samples = image->pimage.layout.nr_samples,
|
||||
.first_level = view->vk.base_mip_level,
|
||||
.last_level = view->vk.base_mip_level +
|
||||
view->vk.level_count - 1,
|
||||
.last_level = view->vk.base_mip_level + view->vk.level_count - 1,
|
||||
.first_layer = view->vk.base_array_layer,
|
||||
.last_layer = view->vk.base_array_layer +
|
||||
view->vk.layer_count - 1,
|
||||
.last_layer = view->vk.base_array_layer + view->vk.layer_count - 1,
|
||||
};
|
||||
panvk_convert_swizzle(&view->vk.swizzle, view->pview.swizzle);
|
||||
|
||||
|
|
@ -127,21 +124,23 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
|
|||
view->bo = panfrost_bo_create(pdev, bo_size, 0, "Texture descriptor");
|
||||
|
||||
STATIC_ASSERT(sizeof(view->descs.tex) >= pan_size(TEXTURE));
|
||||
GENX(panfrost_new_texture)(pdev, &view->pview, &view->descs.tex, &view->bo->ptr);
|
||||
GENX(panfrost_new_texture)
|
||||
(pdev, &view->pview, &view->descs.tex, &view->bo->ptr);
|
||||
}
|
||||
|
||||
if (view->vk.usage & VK_IMAGE_USAGE_STORAGE_BIT) {
|
||||
uint8_t *attrib_buf = (uint8_t *)view->descs.img_attrib_buf;
|
||||
bool is_3d = image->pimage.layout.dim == MALI_TEXTURE_DIMENSION_3D;
|
||||
unsigned offset = image->pimage.data.offset;
|
||||
offset += panfrost_texture_offset(&image->pimage.layout,
|
||||
view->pview.first_level,
|
||||
is_3d ? 0 : view->pview.first_layer,
|
||||
is_3d ? view->pview.first_layer : 0);
|
||||
offset +=
|
||||
panfrost_texture_offset(&image->pimage.layout, view->pview.first_level,
|
||||
is_3d ? 0 : view->pview.first_layer,
|
||||
is_3d ? view->pview.first_layer : 0);
|
||||
|
||||
pan_pack(attrib_buf, ATTRIBUTE_BUFFER, cfg) {
|
||||
cfg.type = image->pimage.layout.modifier == DRM_FORMAT_MOD_LINEAR ?
|
||||
MALI_ATTRIBUTE_TYPE_3D_LINEAR : MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED;
|
||||
cfg.type = image->pimage.layout.modifier == DRM_FORMAT_MOD_LINEAR
|
||||
? MALI_ATTRIBUTE_TYPE_3D_LINEAR
|
||||
: MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED;
|
||||
cfg.pointer = image->pimage.data.bo->ptr.gpu + offset;
|
||||
cfg.stride = util_format_get_blocksize(view->pview.format);
|
||||
cfg.size = image->pimage.data.bo->size - offset;
|
||||
|
|
@ -154,9 +153,9 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
|
|||
cfg.s_dimension = u_minify(image->pimage.layout.width, level);
|
||||
cfg.t_dimension = u_minify(image->pimage.layout.height, level);
|
||||
cfg.r_dimension =
|
||||
view->pview.dim == MALI_TEXTURE_DIMENSION_3D ?
|
||||
u_minify(image->pimage.layout.depth, level) :
|
||||
(view->pview.last_layer - view->pview.first_layer + 1);
|
||||
view->pview.dim == MALI_TEXTURE_DIMENSION_3D
|
||||
? u_minify(image->pimage.layout.depth, level)
|
||||
: (view->pview.last_layer - view->pview.first_layer + 1);
|
||||
cfg.row_stride = image->pimage.layout.slices[level].row_stride;
|
||||
if (cfg.r_dimension > 1) {
|
||||
cfg.slice_stride =
|
||||
|
|
@ -178,9 +177,8 @@ panvk_per_arch(CreateBufferView)(VkDevice _device,
|
|||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_buffer, buffer, pCreateInfo->buffer);
|
||||
|
||||
struct panvk_buffer_view *view =
|
||||
vk_object_zalloc(&device->vk, pAllocator, sizeof(*view),
|
||||
VK_OBJECT_TYPE_BUFFER_VIEW);
|
||||
struct panvk_buffer_view *view = vk_object_zalloc(
|
||||
&device->vk, pAllocator, sizeof(*view), VK_OBJECT_TYPE_BUFFER_VIEW);
|
||||
|
||||
if (!view)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
|
@ -189,8 +187,8 @@ panvk_per_arch(CreateBufferView)(VkDevice _device,
|
|||
|
||||
struct panfrost_device *pdev = &device->physical_device->pdev;
|
||||
mali_ptr address = panvk_buffer_gpu_ptr(buffer, pCreateInfo->offset);
|
||||
unsigned size = panvk_buffer_range(buffer, pCreateInfo->offset,
|
||||
pCreateInfo->range);
|
||||
unsigned size =
|
||||
panvk_buffer_range(buffer, pCreateInfo->offset, pCreateInfo->range);
|
||||
unsigned blksz = util_format_get_blocksize(view->fmt);
|
||||
view->elems = size / blksz;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@
|
|||
#include "vk_format.h"
|
||||
|
||||
mali_ptr
|
||||
panvk_per_arch(meta_emit_viewport)(struct pan_pool *pool,
|
||||
uint16_t minx, uint16_t miny,
|
||||
uint16_t maxx, uint16_t maxy)
|
||||
panvk_per_arch(meta_emit_viewport)(struct pan_pool *pool, uint16_t minx,
|
||||
uint16_t miny, uint16_t maxx, uint16_t maxy)
|
||||
{
|
||||
struct panfrost_ptr vp = pan_pool_alloc_desc(pool, VIEWPORT);
|
||||
|
||||
|
|
@ -53,8 +52,8 @@ panvk_per_arch(meta_init)(struct panvk_physical_device *dev)
|
|||
{
|
||||
panvk_pool_init(&dev->meta.bin_pool, &dev->pdev, NULL, PAN_BO_EXECUTE,
|
||||
16 * 1024, "panvk_meta binary pool", false);
|
||||
panvk_pool_init(&dev->meta.desc_pool, &dev->pdev, NULL, 0,
|
||||
16 * 1024, "panvk_meta descriptor pool", false);
|
||||
panvk_pool_init(&dev->meta.desc_pool, &dev->pdev, NULL, 0, 16 * 1024,
|
||||
"panvk_meta descriptor pool", false);
|
||||
panvk_per_arch(meta_blit_init)(dev);
|
||||
panvk_per_arch(meta_copy_init)(dev);
|
||||
panvk_per_arch(meta_clear_init)(dev);
|
||||
|
|
|
|||
|
|
@ -29,25 +29,18 @@
|
|||
#error "no arch"
|
||||
#endif
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_init)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_init)(struct panvk_physical_device *dev);
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_cleanup)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_cleanup)(struct panvk_physical_device *dev);
|
||||
|
||||
mali_ptr
|
||||
panvk_per_arch(meta_emit_viewport)(struct pan_pool *pool,
|
||||
uint16_t minx, uint16_t miny,
|
||||
uint16_t maxx, uint16_t maxy);
|
||||
mali_ptr panvk_per_arch(meta_emit_viewport)(struct pan_pool *pool,
|
||||
uint16_t minx, uint16_t miny,
|
||||
uint16_t maxx, uint16_t maxy);
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_clear_init)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_clear_init)(struct panvk_physical_device *dev);
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_blit_init)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_blit_init)(struct panvk_physical_device *dev);
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_blit_cleanup)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_blit_cleanup)(struct panvk_physical_device *dev);
|
||||
|
||||
void
|
||||
panvk_per_arch(meta_copy_init)(struct panvk_physical_device *dev);
|
||||
void panvk_per_arch(meta_copy_init)(struct panvk_physical_device *dev);
|
||||
|
|
|
|||
|
|
@ -42,19 +42,23 @@ panvk_meta_blit(struct panvk_cmd_buffer *cmdbuf,
|
|||
.nr_samples = blitinfo->dst.planes[0].image->layout.nr_samples,
|
||||
.first_level = blitinfo->dst.level,
|
||||
.last_level = blitinfo->dst.level,
|
||||
.swizzle = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W },
|
||||
.swizzle = {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z,
|
||||
PIPE_SWIZZLE_W},
|
||||
},
|
||||
};
|
||||
|
||||
*fbinfo = (struct pan_fb_info){
|
||||
.width = u_minify(blitinfo->dst.planes[0].image->layout.width, blitinfo->dst.level),
|
||||
.height = u_minify(blitinfo->dst.planes[0].image->layout.height, blitinfo->dst.level),
|
||||
.extent = {
|
||||
.minx = MAX2(MIN2(blitinfo->dst.start.x, blitinfo->dst.end.x), 0),
|
||||
.miny = MAX2(MIN2(blitinfo->dst.start.y, blitinfo->dst.end.y), 0),
|
||||
.maxx = MAX2(blitinfo->dst.start.x, blitinfo->dst.end.x),
|
||||
.maxy = MAX2(blitinfo->dst.start.y, blitinfo->dst.end.y),
|
||||
},
|
||||
.width = u_minify(blitinfo->dst.planes[0].image->layout.width,
|
||||
blitinfo->dst.level),
|
||||
.height = u_minify(blitinfo->dst.planes[0].image->layout.height,
|
||||
blitinfo->dst.level),
|
||||
.extent =
|
||||
{
|
||||
.minx = MAX2(MIN2(blitinfo->dst.start.x, blitinfo->dst.end.x), 0),
|
||||
.miny = MAX2(MIN2(blitinfo->dst.start.y, blitinfo->dst.end.y), 0),
|
||||
.maxx = MAX2(blitinfo->dst.start.x, blitinfo->dst.end.x),
|
||||
.maxy = MAX2(blitinfo->dst.start.y, blitinfo->dst.end.y),
|
||||
},
|
||||
.nr_samples = blitinfo->dst.planes[0].image->layout.nr_samples,
|
||||
};
|
||||
|
||||
|
|
@ -121,8 +125,8 @@ panvk_meta_blit(struct panvk_cmd_buffer *cmdbuf,
|
|||
tsd = batch->tls.gpu;
|
||||
tiler = batch->tiler.descs.gpu;
|
||||
|
||||
struct panfrost_ptr job =
|
||||
GENX(pan_blit)(&ctx, &cmdbuf->desc_pool.base, &batch->scoreboard, tsd, tiler);
|
||||
struct panfrost_ptr job = GENX(pan_blit)(&ctx, &cmdbuf->desc_pool.base,
|
||||
&batch->scoreboard, tsd, tiler);
|
||||
util_dynarray_append(&batch->jobs, void *, job.cpu);
|
||||
panvk_per_arch(cmd_close_batch)(cmdbuf);
|
||||
} while (pan_blit_next_surface(&ctx));
|
||||
|
|
@ -139,52 +143,64 @@ panvk_per_arch(CmdBlitImage2)(VkCommandBuffer commandBuffer,
|
|||
for (unsigned i = 0; i < pBlitImageInfo->regionCount; i++) {
|
||||
const VkImageBlit2 *region = &pBlitImageInfo->pRegions[i];
|
||||
struct pan_blit_info info = {
|
||||
.src = {
|
||||
.planes[0].image = &src->pimage,
|
||||
.planes[0].format = src->pimage.layout.format,
|
||||
.level = region->srcSubresource.mipLevel,
|
||||
.start = {
|
||||
region->srcOffsets[0].x,
|
||||
region->srcOffsets[0].y,
|
||||
region->srcOffsets[0].z,
|
||||
region->srcSubresource.baseArrayLayer,
|
||||
.src =
|
||||
{
|
||||
.planes[0].image = &src->pimage,
|
||||
.planes[0].format = src->pimage.layout.format,
|
||||
.level = region->srcSubresource.mipLevel,
|
||||
.start =
|
||||
{
|
||||
region->srcOffsets[0].x,
|
||||
region->srcOffsets[0].y,
|
||||
region->srcOffsets[0].z,
|
||||
region->srcSubresource.baseArrayLayer,
|
||||
},
|
||||
.end =
|
||||
{
|
||||
region->srcOffsets[1].x,
|
||||
region->srcOffsets[1].y,
|
||||
region->srcOffsets[1].z,
|
||||
region->srcSubresource.baseArrayLayer +
|
||||
region->srcSubresource.layerCount - 1,
|
||||
},
|
||||
},
|
||||
.end = {
|
||||
region->srcOffsets[1].x,
|
||||
region->srcOffsets[1].y,
|
||||
region->srcOffsets[1].z,
|
||||
region->srcSubresource.baseArrayLayer + region->srcSubresource.layerCount - 1,
|
||||
.dst =
|
||||
{
|
||||
.planes[0].image = &dst->pimage,
|
||||
.planes[0].format = dst->pimage.layout.format,
|
||||
.level = region->dstSubresource.mipLevel,
|
||||
.start =
|
||||
{
|
||||
region->dstOffsets[0].x,
|
||||
region->dstOffsets[0].y,
|
||||
region->dstOffsets[0].z,
|
||||
region->dstSubresource.baseArrayLayer,
|
||||
},
|
||||
.end =
|
||||
{
|
||||
region->dstOffsets[1].x,
|
||||
region->dstOffsets[1].y,
|
||||
region->dstOffsets[1].z,
|
||||
region->dstSubresource.baseArrayLayer +
|
||||
region->dstSubresource.layerCount - 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
.dst = {
|
||||
.planes[0].image = &dst->pimage,
|
||||
.planes[0].format = dst->pimage.layout.format,
|
||||
.level = region->dstSubresource.mipLevel,
|
||||
.start = {
|
||||
region->dstOffsets[0].x,
|
||||
region->dstOffsets[0].y,
|
||||
region->dstOffsets[0].z,
|
||||
region->dstSubresource.baseArrayLayer,
|
||||
},
|
||||
.end = {
|
||||
region->dstOffsets[1].x,
|
||||
region->dstOffsets[1].y,
|
||||
region->dstOffsets[1].z,
|
||||
region->dstSubresource.baseArrayLayer + region->dstSubresource.layerCount - 1,
|
||||
},
|
||||
},
|
||||
.nearest = pBlitImageInfo->filter == VK_FILTER_NEAREST,
|
||||
};
|
||||
|
||||
if (region->srcSubresource.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
info.src.planes[0].format = util_format_stencil_only(info.src.planes[0].format);
|
||||
info.src.planes[0].format =
|
||||
util_format_stencil_only(info.src.planes[0].format);
|
||||
else if (region->srcSubresource.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
info.src.planes[0].format = util_format_get_depth_only(info.src.planes[0].format);
|
||||
info.src.planes[0].format =
|
||||
util_format_get_depth_only(info.src.planes[0].format);
|
||||
|
||||
if (region->dstSubresource.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
info.dst.planes[0].format = util_format_stencil_only(info.dst.planes[0].format);
|
||||
info.dst.planes[0].format =
|
||||
util_format_stencil_only(info.dst.planes[0].format);
|
||||
else if (region->dstSubresource.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
info.dst.planes[0].format = util_format_get_depth_only(info.dst.planes[0].format);
|
||||
info.dst.planes[0].format =
|
||||
util_format_get_depth_only(info.dst.planes[0].format);
|
||||
|
||||
panvk_meta_blit(cmdbuf, &info);
|
||||
}
|
||||
|
|
@ -192,7 +208,7 @@ panvk_per_arch(CmdBlitImage2)(VkCommandBuffer commandBuffer,
|
|||
|
||||
void
|
||||
panvk_per_arch(CmdResolveImage2)(VkCommandBuffer commandBuffer,
|
||||
const VkResolveImageInfo2* pResolveImageInfo)
|
||||
const VkResolveImageInfo2 *pResolveImageInfo)
|
||||
{
|
||||
panvk_stub();
|
||||
}
|
||||
|
|
@ -201,14 +217,14 @@ void
|
|||
panvk_per_arch(meta_blit_init)(struct panvk_physical_device *dev)
|
||||
{
|
||||
panvk_pool_init(&dev->meta.blitter.bin_pool, &dev->pdev, NULL,
|
||||
PAN_BO_EXECUTE, 16 * 1024,
|
||||
"panvk_meta blitter binary pool", false);
|
||||
panvk_pool_init(&dev->meta.blitter.desc_pool, &dev->pdev, NULL,
|
||||
0, 16 * 1024, "panvk_meta blitter descriptor pool",
|
||||
PAN_BO_EXECUTE, 16 * 1024, "panvk_meta blitter binary pool",
|
||||
false);
|
||||
panvk_pool_init(&dev->meta.blitter.desc_pool, &dev->pdev, NULL, 0, 16 * 1024,
|
||||
"panvk_meta blitter descriptor pool", false);
|
||||
pan_blend_shaders_init(&dev->pdev);
|
||||
GENX(pan_blitter_init)(&dev->pdev, &dev->meta.blitter.bin_pool.base,
|
||||
&dev->meta.blitter.desc_pool.base);
|
||||
GENX(pan_blitter_init)
|
||||
(&dev->pdev, &dev->meta.blitter.bin_pool.base,
|
||||
&dev->meta.blitter.desc_pool.base);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -37,19 +37,17 @@ panvk_meta_clear_color_attachment_shader(struct panfrost_device *pdev,
|
|||
enum glsl_base_type base_type,
|
||||
struct pan_shader_info *shader_info)
|
||||
{
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT,
|
||||
GENX(pan_shader_get_compiler_options)(),
|
||||
"panvk_meta_clear_attachment(base_type=%d)",
|
||||
base_type);
|
||||
nir_builder b = nir_builder_init_simple_shader(
|
||||
MESA_SHADER_FRAGMENT, GENX(pan_shader_get_compiler_options)(),
|
||||
"panvk_meta_clear_attachment(base_type=%d)", base_type);
|
||||
|
||||
const struct glsl_type *out_type = glsl_vector_type(base_type, 4);
|
||||
nir_variable *out =
|
||||
nir_variable_create(b.shader, nir_var_shader_out, out_type, "out");
|
||||
out->data.location = FRAG_RESULT_DATA0;
|
||||
|
||||
nir_ssa_def *clear_values = nir_load_push_constant(&b, 4, 32,
|
||||
nir_imm_int(&b, 0),
|
||||
.range = ~0);
|
||||
nir_ssa_def *clear_values =
|
||||
nir_load_push_constant(&b, 4, 32, nir_imm_int(&b, 0), .range = ~0);
|
||||
nir_store_var(&b, out, clear_values, 0xff);
|
||||
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
|
|
@ -78,15 +76,12 @@ panvk_meta_clear_color_attachment_shader(struct panfrost_device *pdev,
|
|||
static mali_ptr
|
||||
panvk_meta_clear_color_attachment_emit_rsd(struct panfrost_device *pdev,
|
||||
struct pan_pool *desc_pool,
|
||||
enum pipe_format format,
|
||||
unsigned rt,
|
||||
enum pipe_format format, unsigned rt,
|
||||
struct pan_shader_info *shader_info,
|
||||
mali_ptr shader)
|
||||
{
|
||||
struct panfrost_ptr rsd_ptr =
|
||||
pan_pool_alloc_desc_aggregate(desc_pool,
|
||||
PAN_DESC(RENDERER_STATE),
|
||||
PAN_DESC_ARRAY(rt + 1, BLEND));
|
||||
struct panfrost_ptr rsd_ptr = pan_pool_alloc_desc_aggregate(
|
||||
desc_pool, PAN_DESC(RENDERER_STATE), PAN_DESC_ARRAY(rt + 1, BLEND));
|
||||
|
||||
pan_pack(rsd_ptr.cpu, RENDERER_STATE, cfg) {
|
||||
pan_shader_prepare_rsd(shader_info, shader, &cfg);
|
||||
|
|
@ -153,9 +148,9 @@ panvk_meta_clear_zs_attachment_emit_rsd(struct panfrost_device *pdev,
|
|||
cfg.stencil_mask_misc.stencil_mask_front = 0xFF;
|
||||
cfg.stencil_mask_misc.stencil_mask_back = 0xFF;
|
||||
|
||||
cfg.stencil_front.compare_function =
|
||||
(mask & VK_IMAGE_ASPECT_DEPTH_BIT) ?
|
||||
MALI_FUNC_ALWAYS : MALI_FUNC_NOT_EQUAL;
|
||||
cfg.stencil_front.compare_function = (mask & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
? MALI_FUNC_ALWAYS
|
||||
: MALI_FUNC_NOT_EQUAL;
|
||||
|
||||
cfg.stencil_front.stencil_fail = MALI_STENCIL_OP_KEEP;
|
||||
cfg.stencil_front.depth_fail = MALI_STENCIL_OP_REPLACE;
|
||||
|
|
@ -174,10 +169,9 @@ panvk_meta_clear_zs_attachment_emit_rsd(struct panfrost_device *pdev,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_meta_clear_attachment_emit_dcd(struct pan_pool *pool,
|
||||
mali_ptr coords, mali_ptr push_constants,
|
||||
mali_ptr vpd, mali_ptr tsd, mali_ptr rsd,
|
||||
void *out)
|
||||
panvk_meta_clear_attachment_emit_dcd(struct pan_pool *pool, mali_ptr coords,
|
||||
mali_ptr push_constants, mali_ptr vpd,
|
||||
mali_ptr tsd, mali_ptr rsd, void *out)
|
||||
{
|
||||
pan_pack(out, DRAW, cfg) {
|
||||
cfg.thread_storage = tsd;
|
||||
|
|
@ -196,14 +190,11 @@ panvk_meta_clear_attachment_emit_tiler_job(struct pan_pool *desc_pool,
|
|||
mali_ptr vpd, mali_ptr rsd,
|
||||
mali_ptr tsd, mali_ptr tiler)
|
||||
{
|
||||
struct panfrost_ptr job =
|
||||
pan_pool_alloc_desc(desc_pool, TILER_JOB);
|
||||
struct panfrost_ptr job = pan_pool_alloc_desc(desc_pool, TILER_JOB);
|
||||
|
||||
panvk_meta_clear_attachment_emit_dcd(desc_pool,
|
||||
coords,
|
||||
push_constants,
|
||||
vpd, tsd, rsd,
|
||||
pan_section_ptr(job.cpu, TILER_JOB, DRAW));
|
||||
panvk_meta_clear_attachment_emit_dcd(
|
||||
desc_pool, coords, push_constants, vpd, tsd, rsd,
|
||||
pan_section_ptr(job.cpu, TILER_JOB, DRAW));
|
||||
|
||||
pan_section_pack(job.cpu, TILER_JOB, PRIMITIVE, cfg) {
|
||||
cfg.draw_mode = MALI_DRAW_MODE_TRIANGLE_STRIP;
|
||||
|
|
@ -215,19 +206,17 @@ panvk_meta_clear_attachment_emit_tiler_job(struct pan_pool *desc_pool,
|
|||
cfg.constant = 1.0f;
|
||||
}
|
||||
|
||||
void *invoc = pan_section_ptr(job.cpu,
|
||||
TILER_JOB,
|
||||
INVOCATION);
|
||||
panfrost_pack_work_groups_compute(invoc, 1, 4,
|
||||
1, 1, 1, 1, true, false);
|
||||
void *invoc = pan_section_ptr(job.cpu, TILER_JOB, INVOCATION);
|
||||
panfrost_pack_work_groups_compute(invoc, 1, 4, 1, 1, 1, 1, true, false);
|
||||
|
||||
pan_section_pack(job.cpu, TILER_JOB, PADDING, cfg);
|
||||
pan_section_pack(job.cpu, TILER_JOB, PADDING, cfg)
|
||||
;
|
||||
pan_section_pack(job.cpu, TILER_JOB, TILER, cfg) {
|
||||
cfg.address = tiler;
|
||||
}
|
||||
|
||||
panfrost_add_job(desc_pool, scoreboard, MALI_JOB_TYPE_TILER,
|
||||
false, false, 0, 0, &job, false);
|
||||
panfrost_add_job(desc_pool, scoreboard, MALI_JOB_TYPE_TILER, false, false, 0,
|
||||
0, &job, false);
|
||||
return job;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +232,7 @@ panvk_meta_get_format_type(enum pipe_format format)
|
|||
if (desc->channel[i].normalized)
|
||||
return GLSL_TYPE_FLOAT;
|
||||
|
||||
switch(desc->channel[i].type) {
|
||||
switch (desc->channel[i].type) {
|
||||
|
||||
case UTIL_FORMAT_TYPE_UNSIGNED:
|
||||
return GLSL_TYPE_UINT;
|
||||
|
|
@ -272,28 +261,28 @@ panvk_meta_clear_attachment(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct panvk_meta *meta = &cmdbuf->device->physical_device->meta;
|
||||
struct panvk_batch *batch = cmdbuf->state.batch;
|
||||
const struct panvk_render_pass *pass = cmdbuf->state.pass;
|
||||
const struct panvk_render_pass_attachment *att = &pass->attachments[attachment];
|
||||
const struct panvk_render_pass_attachment *att =
|
||||
&pass->attachments[attachment];
|
||||
unsigned minx = MAX2(clear_rect->rect.offset.x, 0);
|
||||
unsigned miny = MAX2(clear_rect->rect.offset.y, 0);
|
||||
unsigned maxx = MAX2(clear_rect->rect.offset.x + clear_rect->rect.extent.width - 1, 0);
|
||||
unsigned maxy = MAX2(clear_rect->rect.offset.y + clear_rect->rect.extent.height - 1, 0);
|
||||
unsigned maxx =
|
||||
MAX2(clear_rect->rect.offset.x + clear_rect->rect.extent.width - 1, 0);
|
||||
unsigned maxy =
|
||||
MAX2(clear_rect->rect.offset.y + clear_rect->rect.extent.height - 1, 0);
|
||||
|
||||
panvk_per_arch(cmd_alloc_fb_desc)(cmdbuf);
|
||||
panvk_per_arch(cmd_alloc_tls_desc)(cmdbuf, true);
|
||||
panvk_per_arch(cmd_prepare_tiler_context)(cmdbuf);
|
||||
|
||||
mali_ptr vpd =
|
||||
panvk_per_arch(meta_emit_viewport)(&cmdbuf->desc_pool.base,
|
||||
minx, miny, maxx, maxy);
|
||||
mali_ptr vpd = panvk_per_arch(meta_emit_viewport)(&cmdbuf->desc_pool.base,
|
||||
minx, miny, maxx, maxy);
|
||||
|
||||
float rect[] = {
|
||||
minx, miny, 0.0, 1.0,
|
||||
maxx + 1, miny, 0.0, 1.0,
|
||||
minx, maxy + 1, 0.0, 1.0,
|
||||
maxx + 1, maxy + 1, 0.0, 1.0,
|
||||
minx, miny, 0.0, 1.0, maxx + 1, miny, 0.0, 1.0,
|
||||
minx, maxy + 1, 0.0, 1.0, maxx + 1, maxy + 1, 0.0, 1.0,
|
||||
};
|
||||
mali_ptr coordinates = pan_pool_upload_aligned(&cmdbuf->desc_pool.base,
|
||||
rect, sizeof(rect), 64);
|
||||
mali_ptr coordinates =
|
||||
pan_pool_upload_aligned(&cmdbuf->desc_pool.base, rect, sizeof(rect), 64);
|
||||
|
||||
enum glsl_base_type base_type = panvk_meta_get_format_type(att->format);
|
||||
|
||||
|
|
@ -304,29 +293,24 @@ panvk_meta_clear_attachment(struct panvk_cmd_buffer *cmdbuf,
|
|||
|
||||
if (mask & VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
mali_ptr shader = meta->clear_attachment.color[base_type].shader;
|
||||
struct pan_shader_info *shader_info = &meta->clear_attachment.color[base_type].shader_info;
|
||||
struct pan_shader_info *shader_info =
|
||||
&meta->clear_attachment.color[base_type].shader_info;
|
||||
|
||||
pushconsts = pan_pool_upload_aligned(&cmdbuf->desc_pool.base,
|
||||
clear_value, sizeof(*clear_value), 16);
|
||||
pushconsts = pan_pool_upload_aligned(&cmdbuf->desc_pool.base, clear_value,
|
||||
sizeof(*clear_value), 16);
|
||||
|
||||
rsd = panvk_meta_clear_color_attachment_emit_rsd(pdev,
|
||||
&cmdbuf->desc_pool.base,
|
||||
att->format, rt,
|
||||
shader_info,
|
||||
shader);
|
||||
rsd = panvk_meta_clear_color_attachment_emit_rsd(
|
||||
pdev, &cmdbuf->desc_pool.base, att->format, rt, shader_info, shader);
|
||||
} else {
|
||||
rsd = panvk_meta_clear_zs_attachment_emit_rsd(pdev,
|
||||
&cmdbuf->desc_pool.base,
|
||||
mask,
|
||||
clear_value->depthStencil);
|
||||
rsd = panvk_meta_clear_zs_attachment_emit_rsd(
|
||||
pdev, &cmdbuf->desc_pool.base, mask, clear_value->depthStencil);
|
||||
}
|
||||
|
||||
struct panfrost_ptr job;
|
||||
|
||||
job = panvk_meta_clear_attachment_emit_tiler_job(&cmdbuf->desc_pool.base,
|
||||
&batch->scoreboard,
|
||||
coordinates, pushconsts,
|
||||
vpd, rsd, tsd, tiler);
|
||||
job = panvk_meta_clear_attachment_emit_tiler_job(
|
||||
&cmdbuf->desc_pool.base, &batch->scoreboard, coordinates, pushconsts, vpd,
|
||||
rsd, tsd, tiler);
|
||||
|
||||
util_dynarray_append(&batch->jobs, void *, job.cpu);
|
||||
}
|
||||
|
|
@ -343,7 +327,8 @@ panvk_meta_clear_color_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.image = &img->pimage,
|
||||
.nr_samples = img->pimage.layout.nr_samples,
|
||||
.swizzle = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W },
|
||||
.swizzle = {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z,
|
||||
PIPE_SWIZZLE_W},
|
||||
};
|
||||
|
||||
cmdbuf->state.fb.crc_valid[0] = false;
|
||||
|
|
@ -358,7 +343,8 @@ panvk_meta_clear_color_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
uint32_t clearval[4];
|
||||
pan_pack_color(clearval, (union pipe_color_union *)color,
|
||||
img->pimage.layout.format, false);
|
||||
memcpy(fbinfo->rts[0].clear_value, clearval, sizeof(fbinfo->rts[0].clear_value));
|
||||
memcpy(fbinfo->rts[0].clear_value, clearval,
|
||||
sizeof(fbinfo->rts[0].clear_value));
|
||||
|
||||
unsigned level_count = vk_image_subresource_level_count(&img->vk, range);
|
||||
unsigned layer_count = vk_image_subresource_layer_count(&img->vk, range);
|
||||
|
|
@ -382,8 +368,7 @@ panvk_meta_clear_color_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdClearColorImage)(VkCommandBuffer commandBuffer,
|
||||
VkImage image,
|
||||
panvk_per_arch(CmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image,
|
||||
VkImageLayout imageLayout,
|
||||
const VkClearColorValue *pColor,
|
||||
uint32_t rangeCount,
|
||||
|
|
@ -410,7 +395,8 @@ panvk_meta_clear_zs_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.image = &img->pimage,
|
||||
.nr_samples = img->pimage.layout.nr_samples,
|
||||
.swizzle = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W },
|
||||
.swizzle = {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z,
|
||||
PIPE_SWIZZLE_W},
|
||||
};
|
||||
|
||||
cmdbuf->state.fb.crc_valid[0] = false;
|
||||
|
|
@ -420,8 +406,7 @@ panvk_meta_clear_zs_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
.zs.clear_value.depth = value->depth,
|
||||
.zs.clear_value.stencil = value->stencil,
|
||||
.zs.clear.z = range->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT,
|
||||
.zs.clear.s = range->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT
|
||||
};
|
||||
.zs.clear.s = range->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT};
|
||||
|
||||
const struct util_format_description *fdesc =
|
||||
util_format_description(view.format);
|
||||
|
|
@ -458,12 +443,10 @@ panvk_meta_clear_zs_img(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(CmdClearDepthStencilImage)(VkCommandBuffer commandBuffer,
|
||||
VkImage image,
|
||||
VkImageLayout imageLayout,
|
||||
const VkClearDepthStencilValue *pDepthStencil,
|
||||
uint32_t rangeCount,
|
||||
const VkImageSubresourceRange *pRanges)
|
||||
panvk_per_arch(CmdClearDepthStencilImage)(
|
||||
VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout,
|
||||
const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount,
|
||||
const VkImageSubresourceRange *pRanges)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
|
||||
VK_FROM_HANDLE(panvk_image, img, image);
|
||||
|
|
@ -496,12 +479,11 @@ panvk_per_arch(CmdClearAttachments)(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
if (attachment == VK_ATTACHMENT_UNUSED)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
panvk_meta_clear_attachment(cmdbuf, attachment, rt,
|
||||
pAttachments[i].aspectMask,
|
||||
&pAttachments[i].clearValue,
|
||||
&pRects[j]);
|
||||
&pAttachments[i].clearValue, &pRects[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -511,24 +493,18 @@ panvk_meta_clear_attachment_init(struct panvk_physical_device *dev)
|
|||
{
|
||||
dev->meta.clear_attachment.color[GLSL_TYPE_UINT].shader =
|
||||
panvk_meta_clear_color_attachment_shader(
|
||||
&dev->pdev,
|
||||
&dev->meta.bin_pool.base,
|
||||
GLSL_TYPE_UINT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_UINT].shader_info);
|
||||
&dev->pdev, &dev->meta.bin_pool.base, GLSL_TYPE_UINT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_UINT].shader_info);
|
||||
|
||||
dev->meta.clear_attachment.color[GLSL_TYPE_INT].shader =
|
||||
panvk_meta_clear_color_attachment_shader(
|
||||
&dev->pdev,
|
||||
&dev->meta.bin_pool.base,
|
||||
GLSL_TYPE_INT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_INT].shader_info);
|
||||
&dev->pdev, &dev->meta.bin_pool.base, GLSL_TYPE_INT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_INT].shader_info);
|
||||
|
||||
dev->meta.clear_attachment.color[GLSL_TYPE_FLOAT].shader =
|
||||
panvk_meta_clear_color_attachment_shader(
|
||||
&dev->pdev,
|
||||
&dev->meta.bin_pool.base,
|
||||
GLSL_TYPE_FLOAT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_FLOAT].shader_info);
|
||||
&dev->pdev, &dev->meta.bin_pool.base, GLSL_TYPE_FLOAT,
|
||||
&dev->meta.clear_attachment.color[GLSL_TYPE_FLOAT].shader_info);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -125,33 +125,30 @@ build_res_index(nir_builder *b, uint32_t set, uint32_t binding,
|
|||
panvk_pipeline_layout_ubo_start(ctx->layout, set, false) +
|
||||
set_layout->desc_ubo_index;
|
||||
|
||||
const uint32_t packed = (bind_layout->desc_ubo_stride << 16 ) |
|
||||
set_ubo_idx;
|
||||
const uint32_t packed =
|
||||
(bind_layout->desc_ubo_stride << 16) | set_ubo_idx;
|
||||
|
||||
return nir_vec4(b, nir_imm_int(b, packed),
|
||||
nir_imm_int(b, bind_layout->desc_ubo_offset),
|
||||
nir_imm_int(b, array_size - 1),
|
||||
array_index);
|
||||
nir_imm_int(b, bind_layout->desc_ubo_offset),
|
||||
nir_imm_int(b, array_size - 1), array_index);
|
||||
}
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
|
||||
assert(addr_format == nir_address_format_64bit_bounded_global ||
|
||||
addr_format == nir_address_format_64bit_global_32bit_offset);
|
||||
|
||||
const unsigned dyn_ssbo_idx = ctx->layout->sets[set].dyn_ssbo_offset +
|
||||
bind_layout->dyn_ssbo_idx;
|
||||
const unsigned dyn_ssbo_idx =
|
||||
ctx->layout->sets[set].dyn_ssbo_offset + bind_layout->dyn_ssbo_idx;
|
||||
|
||||
const unsigned ubo_idx = PANVK_SYSVAL_UBO_INDEX;
|
||||
const unsigned desc_stride = sizeof(struct panvk_ssbo_addr);
|
||||
const uint32_t ubo_offset = offsetof(struct panvk_sysvals, dyn_ssbos) +
|
||||
dyn_ssbo_idx * desc_stride;
|
||||
const uint32_t ubo_offset =
|
||||
offsetof(struct panvk_sysvals, dyn_ssbos) + dyn_ssbo_idx * desc_stride;
|
||||
|
||||
const uint32_t packed = (desc_stride << 16) | ubo_idx;
|
||||
|
||||
return nir_vec4(b, nir_imm_int(b, packed),
|
||||
nir_imm_int(b, ubo_offset),
|
||||
nir_imm_int(b, array_size - 1),
|
||||
array_index);
|
||||
return nir_vec4(b, nir_imm_int(b, packed), nir_imm_int(b, ubo_offset),
|
||||
nir_imm_int(b, array_size - 1), array_index);
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
@ -174,14 +171,13 @@ build_res_reindex(nir_builder *b, nir_ssa_def *orig, nir_ssa_def *delta,
|
|||
switch (addr_format) {
|
||||
case nir_address_format_32bit_index_offset:
|
||||
return nir_vec2(b, nir_channel(b, orig, 0),
|
||||
nir_iadd(b, nir_channel(b, orig, 1), delta));
|
||||
nir_iadd(b, nir_channel(b, orig, 1), delta));
|
||||
|
||||
case nir_address_format_64bit_bounded_global:
|
||||
case nir_address_format_64bit_global_32bit_offset:
|
||||
return nir_vec4(b, nir_channel(b, orig, 0),
|
||||
nir_channel(b, orig, 1),
|
||||
nir_channel(b, orig, 2),
|
||||
nir_iadd(b, nir_channel(b, orig, 3), delta));
|
||||
return nir_vec4(b, nir_channel(b, orig, 0), nir_channel(b, orig, 1),
|
||||
nir_channel(b, orig, 2),
|
||||
nir_iadd(b, nir_channel(b, orig, 3), delta));
|
||||
|
||||
default:
|
||||
unreachable("Unhandled address format");
|
||||
|
|
@ -196,8 +192,7 @@ build_res_reindex(nir_builder *b, nir_ssa_def *orig, nir_ssa_def *delta,
|
|||
* See build_res_index for details about each resource index format.
|
||||
*/
|
||||
static nir_ssa_def *
|
||||
build_buffer_addr_for_res_index(nir_builder *b,
|
||||
nir_ssa_def *res_index,
|
||||
build_buffer_addr_for_res_index(nir_builder *b, nir_ssa_def *res_index,
|
||||
nir_address_format addr_format,
|
||||
const struct apply_descriptors_ctx *ctx)
|
||||
{
|
||||
|
|
@ -205,14 +200,15 @@ build_buffer_addr_for_res_index(nir_builder *b,
|
|||
case nir_address_format_32bit_index_offset: {
|
||||
nir_ssa_def *packed = nir_channel(b, res_index, 0);
|
||||
nir_ssa_def *array_index = nir_channel(b, res_index, 1);
|
||||
nir_ssa_def *surface_index = nir_extract_u16(b, packed, nir_imm_int(b, 0));
|
||||
nir_ssa_def *surface_index =
|
||||
nir_extract_u16(b, packed, nir_imm_int(b, 0));
|
||||
nir_ssa_def *array_max = nir_extract_u16(b, packed, nir_imm_int(b, 1));
|
||||
|
||||
if (ctx->add_bounds_checks)
|
||||
array_index = nir_umin(b, array_index, array_max);
|
||||
|
||||
return nir_vec2(b, nir_iadd(b, surface_index, array_index),
|
||||
nir_imm_int(b, 0));
|
||||
nir_imm_int(b, 0));
|
||||
}
|
||||
|
||||
case nir_address_format_64bit_bounded_global:
|
||||
|
|
@ -223,26 +219,24 @@ build_buffer_addr_for_res_index(nir_builder *b,
|
|||
nir_ssa_def *array_index = nir_channel(b, res_index, 3);
|
||||
|
||||
nir_ssa_def *desc_ubo_idx = nir_extract_u16(b, packed, nir_imm_int(b, 0));
|
||||
nir_ssa_def *desc_ubo_stride = nir_extract_u16(b, packed, nir_imm_int(b, 1));
|
||||
nir_ssa_def *desc_ubo_stride =
|
||||
nir_extract_u16(b, packed, nir_imm_int(b, 1));
|
||||
|
||||
if (ctx->add_bounds_checks)
|
||||
array_index = nir_umin(b, array_index, array_max);
|
||||
|
||||
desc_ubo_offset = nir_iadd(b, desc_ubo_offset,
|
||||
nir_imul(b, array_index, desc_ubo_stride));
|
||||
nir_imul(b, array_index, desc_ubo_stride));
|
||||
|
||||
nir_ssa_def *desc = nir_load_ubo(b, 4, 32, desc_ubo_idx,
|
||||
desc_ubo_offset,
|
||||
.align_mul=16, .range=~0);
|
||||
nir_ssa_def *desc = nir_load_ubo(b, 4, 32, desc_ubo_idx, desc_ubo_offset,
|
||||
.align_mul = 16, .range = ~0);
|
||||
|
||||
/* The offset in the descriptor is guaranteed to be zero when it's
|
||||
* written into the descriptor set. This lets us avoid some unnecessary
|
||||
* adds.
|
||||
*/
|
||||
return nir_vec4(b, nir_channel(b, desc, 0),
|
||||
nir_channel(b, desc, 1),
|
||||
nir_channel(b, desc, 2),
|
||||
nir_imm_int(b, 0));
|
||||
return nir_vec4(b, nir_channel(b, desc, 0), nir_channel(b, desc, 1),
|
||||
nir_channel(b, desc, 2), nir_imm_int(b, 0));
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
@ -250,7 +244,6 @@ build_buffer_addr_for_res_index(nir_builder *b,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
lower_res_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct apply_descriptors_ctx *ctx)
|
||||
|
|
@ -265,22 +258,20 @@ lower_res_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
case nir_intrinsic_vulkan_resource_index:
|
||||
assert(intrin->src[0].is_ssa);
|
||||
res = build_res_index(b, nir_intrinsic_desc_set(intrin),
|
||||
nir_intrinsic_binding(intrin),
|
||||
intrin->src[0].ssa,
|
||||
addr_format, ctx);
|
||||
nir_intrinsic_binding(intrin), intrin->src[0].ssa,
|
||||
addr_format, ctx);
|
||||
break;
|
||||
|
||||
case nir_intrinsic_vulkan_resource_reindex:
|
||||
assert(intrin->src[0].is_ssa && intrin->src[1].is_ssa);
|
||||
res = build_res_reindex(b, intrin->src[0].ssa,
|
||||
intrin->src[1].ssa,
|
||||
addr_format);
|
||||
res = build_res_reindex(b, intrin->src[0].ssa, intrin->src[1].ssa,
|
||||
addr_format);
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_vulkan_descriptor:
|
||||
assert(intrin->src[0].is_ssa);
|
||||
res = build_buffer_addr_for_res_index(b, intrin->src[0].ssa,
|
||||
addr_format, ctx);
|
||||
res = build_buffer_addr_for_res_index(b, intrin->src[0].ssa, addr_format,
|
||||
ctx);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -297,9 +288,9 @@ lower_res_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
}
|
||||
|
||||
static void
|
||||
get_resource_deref_binding(nir_deref_instr *deref,
|
||||
uint32_t *set, uint32_t *binding,
|
||||
uint32_t *index_imm, nir_ssa_def **index_ssa)
|
||||
get_resource_deref_binding(nir_deref_instr *deref, uint32_t *set,
|
||||
uint32_t *binding, uint32_t *index_imm,
|
||||
nir_ssa_def **index_ssa)
|
||||
{
|
||||
*index_imm = 0;
|
||||
*index_ssa = NULL;
|
||||
|
|
@ -323,14 +314,13 @@ get_resource_deref_binding(nir_deref_instr *deref,
|
|||
|
||||
static nir_ssa_def *
|
||||
load_resource_deref_desc(nir_builder *b, nir_deref_instr *deref,
|
||||
unsigned desc_offset,
|
||||
unsigned num_components, unsigned bit_size,
|
||||
unsigned desc_offset, unsigned num_components,
|
||||
unsigned bit_size,
|
||||
const struct apply_descriptors_ctx *ctx)
|
||||
{
|
||||
uint32_t set, binding, index_imm;
|
||||
nir_ssa_def *index_ssa;
|
||||
get_resource_deref_binding(deref, &set, &binding,
|
||||
&index_imm, &index_ssa);
|
||||
get_resource_deref_binding(deref, &set, &binding, &index_imm, &index_ssa);
|
||||
|
||||
const struct panvk_descriptor_set_layout *set_layout =
|
||||
get_set_layout(set, ctx);
|
||||
|
|
@ -346,20 +336,16 @@ load_resource_deref_desc(nir_builder *b, nir_deref_instr *deref,
|
|||
set_layout->desc_ubo_index;
|
||||
|
||||
nir_ssa_def *desc_ubo_offset =
|
||||
nir_iadd_imm(b, nir_imul_imm(b, index_ssa,
|
||||
bind_layout->desc_ubo_stride),
|
||||
bind_layout->desc_ubo_offset + desc_offset);
|
||||
nir_iadd_imm(b, nir_imul_imm(b, index_ssa, bind_layout->desc_ubo_stride),
|
||||
bind_layout->desc_ubo_offset + desc_offset);
|
||||
|
||||
assert(bind_layout->desc_ubo_stride > 0);
|
||||
unsigned desc_align = (1 << (ffs(bind_layout->desc_ubo_stride) - 1));
|
||||
desc_align = MIN2(desc_align, 16);
|
||||
|
||||
return nir_load_ubo(b, num_components, bit_size,
|
||||
nir_imm_int(b, set_ubo_idx),
|
||||
desc_ubo_offset,
|
||||
.align_mul=desc_align,
|
||||
.align_offset=(desc_offset % desc_align),
|
||||
.range=~0);
|
||||
return nir_load_ubo(b, num_components, bit_size, nir_imm_int(b, set_ubo_idx),
|
||||
desc_ubo_offset, .align_mul = desc_align,
|
||||
.align_offset = (desc_offset % desc_align), .range = ~0);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
|
|
@ -407,8 +393,7 @@ lower_tex(nir_builder *b, nir_tex_instr *tex,
|
|||
|
||||
b->cursor = nir_before_instr(&tex->instr);
|
||||
|
||||
if (tex->op == nir_texop_txs ||
|
||||
tex->op == nir_texop_query_levels ||
|
||||
if (tex->op == nir_texop_txs || tex->op == nir_texop_query_levels ||
|
||||
tex->op == nir_texop_texture_samples) {
|
||||
int tex_src_idx = nir_tex_instr_src_index(tex, nir_tex_src_texture_deref);
|
||||
assert(tex_src_idx >= 0);
|
||||
|
|
@ -439,15 +424,15 @@ lower_tex(nir_builder *b, nir_tex_instr *tex,
|
|||
return true;
|
||||
}
|
||||
|
||||
int sampler_src_idx = nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref);
|
||||
int sampler_src_idx =
|
||||
nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref);
|
||||
if (sampler_src_idx >= 0) {
|
||||
nir_deref_instr *deref = nir_src_as_deref(tex->src[sampler_src_idx].src);
|
||||
nir_tex_instr_remove_src(tex, sampler_src_idx);
|
||||
|
||||
uint32_t set, binding, index_imm;
|
||||
nir_ssa_def *index_ssa;
|
||||
get_resource_deref_binding(deref, &set, &binding,
|
||||
&index_imm, &index_ssa);
|
||||
get_resource_deref_binding(deref, &set, &binding, &index_imm, &index_ssa);
|
||||
|
||||
const struct panvk_descriptor_set_binding_layout *bind_layout =
|
||||
get_binding_layout(set, binding, ctx);
|
||||
|
|
@ -469,14 +454,13 @@ lower_tex(nir_builder *b, nir_tex_instr *tex,
|
|||
|
||||
uint32_t set, binding, index_imm;
|
||||
nir_ssa_def *index_ssa;
|
||||
get_resource_deref_binding(deref, &set, &binding,
|
||||
&index_imm, &index_ssa);
|
||||
get_resource_deref_binding(deref, &set, &binding, &index_imm, &index_ssa);
|
||||
|
||||
const struct panvk_descriptor_set_binding_layout *bind_layout =
|
||||
get_binding_layout(set, binding, ctx);
|
||||
|
||||
tex->texture_index = ctx->layout->sets[set].tex_offset +
|
||||
bind_layout->tex_idx + index_imm;
|
||||
tex->texture_index =
|
||||
ctx->layout->sets[set].tex_offset + bind_layout->tex_idx + index_imm;
|
||||
|
||||
if (index_ssa != NULL) {
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_texture_offset,
|
||||
|
|
@ -502,8 +486,8 @@ get_img_index(nir_builder *b, nir_deref_instr *deref,
|
|||
bind_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER ||
|
||||
bind_layout->type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER);
|
||||
|
||||
unsigned img_offset = ctx->layout->sets[set].img_offset +
|
||||
bind_layout->img_idx;
|
||||
unsigned img_offset =
|
||||
ctx->layout->sets[set].img_offset + bind_layout->img_idx;
|
||||
|
||||
if (index_ssa == NULL) {
|
||||
return nir_imm_int(b, img_offset + index_imm);
|
||||
|
|
@ -577,13 +561,10 @@ lower_intrinsic(nir_builder *b, nir_intrinsic_instr *intr,
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_descriptors_instr(nir_builder *b,
|
||||
nir_instr *instr,
|
||||
void *data)
|
||||
lower_descriptors_instr(nir_builder *b, nir_instr *instr, void *data)
|
||||
{
|
||||
struct apply_descriptors_ctx *ctx = data;
|
||||
|
||||
|
|
@ -598,8 +579,7 @@ lower_descriptors_instr(nir_builder *b,
|
|||
}
|
||||
|
||||
bool
|
||||
panvk_per_arch(nir_lower_descriptors)(nir_shader *nir,
|
||||
struct panvk_device *dev,
|
||||
panvk_per_arch(nir_lower_descriptors)(nir_shader *nir, struct panvk_device *dev,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
bool *has_img_access_out)
|
||||
{
|
||||
|
|
@ -607,15 +587,14 @@ panvk_per_arch(nir_lower_descriptors)(nir_shader *nir,
|
|||
.layout = layout,
|
||||
.desc_addr_format = nir_address_format_32bit_index_offset,
|
||||
.ubo_addr_format = nir_address_format_32bit_index_offset,
|
||||
.ssbo_addr_format = dev->vk.enabled_features.robustBufferAccess ?
|
||||
nir_address_format_64bit_bounded_global :
|
||||
nir_address_format_64bit_global_32bit_offset,
|
||||
.ssbo_addr_format = dev->vk.enabled_features.robustBufferAccess
|
||||
? nir_address_format_64bit_bounded_global
|
||||
: nir_address_format_64bit_global_32bit_offset,
|
||||
};
|
||||
|
||||
bool progress = nir_shader_instructions_pass(nir, lower_descriptors_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
(void *)&ctx);
|
||||
bool progress = nir_shader_instructions_pass(
|
||||
nir, lower_descriptors_instr,
|
||||
nir_metadata_block_index | nir_metadata_dominance, (void *)&ctx);
|
||||
if (has_img_access_out)
|
||||
*has_img_access_out = ctx.has_img_access;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,17 +34,15 @@
|
|||
#include "nir/nir.h"
|
||||
#include "nir/nir_builder.h"
|
||||
#include "spirv/nir_spirv.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include "panfrost/util/pan_lower_framebuffer.h"
|
||||
|
||||
|
||||
struct panvk_pipeline_builder
|
||||
{
|
||||
struct panvk_pipeline_builder {
|
||||
struct panvk_device *device;
|
||||
struct panvk_pipeline_cache *cache;
|
||||
const VkAllocationCallbacks *alloc;
|
||||
|
|
@ -78,9 +76,8 @@ panvk_pipeline_builder_create_pipeline(struct panvk_pipeline_builder *builder,
|
|||
{
|
||||
struct panvk_device *dev = builder->device;
|
||||
|
||||
struct panvk_pipeline *pipeline =
|
||||
vk_object_zalloc(&dev->vk, builder->alloc,
|
||||
sizeof(*pipeline), VK_OBJECT_TYPE_PIPELINE);
|
||||
struct panvk_pipeline *pipeline = vk_object_zalloc(
|
||||
&dev->vk, builder->alloc, sizeof(*pipeline), VK_OBJECT_TYPE_PIPELINE);
|
||||
if (!pipeline)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
|
|
@ -95,7 +92,8 @@ panvk_pipeline_builder_finish(struct panvk_pipeline_builder *builder)
|
|||
for (uint32_t i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
if (!builder->shaders[i])
|
||||
continue;
|
||||
panvk_shader_destroy(builder->device, builder->shaders[i], builder->alloc);
|
||||
panvk_shader_destroy(builder->device, builder->shaders[i],
|
||||
builder->alloc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,12 +108,10 @@ panvk_pipeline_builder_compile_shaders(struct panvk_pipeline_builder *builder,
|
|||
struct panvk_pipeline *pipeline)
|
||||
{
|
||||
const VkPipelineShaderStageCreateInfo *stage_infos[MESA_SHADER_STAGES] = {
|
||||
NULL
|
||||
};
|
||||
NULL};
|
||||
const VkPipelineShaderStageCreateInfo *stages =
|
||||
builder->create_info.gfx ?
|
||||
builder->create_info.gfx->pStages :
|
||||
&builder->create_info.compute->stage;
|
||||
builder->create_info.gfx ? builder->create_info.gfx->pStages
|
||||
: &builder->create_info.compute->stage;
|
||||
unsigned stage_count =
|
||||
builder->create_info.gfx ? builder->create_info.gfx->stageCount : 1;
|
||||
|
||||
|
|
@ -133,16 +129,15 @@ panvk_pipeline_builder_compile_shaders(struct panvk_pipeline_builder *builder,
|
|||
|
||||
struct panvk_shader *shader;
|
||||
|
||||
shader = panvk_per_arch(shader_create)(builder->device, stage, stage_info,
|
||||
builder->layout,
|
||||
PANVK_SYSVAL_UBO_INDEX,
|
||||
&pipeline->blend.state,
|
||||
panvk_pipeline_static_state(pipeline,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS),
|
||||
builder->alloc);
|
||||
shader = panvk_per_arch(shader_create)(
|
||||
builder->device, stage, stage_info, builder->layout,
|
||||
PANVK_SYSVAL_UBO_INDEX, &pipeline->blend.state,
|
||||
panvk_pipeline_static_state(pipeline,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS),
|
||||
builder->alloc);
|
||||
if (!shader)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
|
||||
builder->shaders[stage] = shader;
|
||||
builder->shader_total_size = ALIGN_POT(builder->shader_total_size, 128);
|
||||
builder->stages[stage].shader_offset = builder->shader_total_size;
|
||||
|
|
@ -165,8 +160,7 @@ panvk_pipeline_builder_upload_shaders(struct panvk_pipeline_builder *builder,
|
|||
|
||||
struct panfrost_bo *bin_bo =
|
||||
panfrost_bo_create(&builder->device->physical_device->pdev,
|
||||
builder->shader_total_size, PAN_BO_EXECUTE,
|
||||
"Shader");
|
||||
builder->shader_total_size, PAN_BO_EXECUTE, "Shader");
|
||||
|
||||
pipeline->binary_bo = bin_bo;
|
||||
panfrost_bo_mmap(bin_bo);
|
||||
|
|
@ -185,11 +179,10 @@ panvk_pipeline_builder_upload_shaders(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_alloc_static_state_bo(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
panvk_pipeline_builder_alloc_static_state_bo(
|
||||
struct panvk_pipeline_builder *builder, struct panvk_pipeline *pipeline)
|
||||
{
|
||||
struct panfrost_device *pdev =
|
||||
&builder->device->physical_device->pdev;
|
||||
struct panfrost_device *pdev = &builder->device->physical_device->pdev;
|
||||
unsigned bo_size = 0;
|
||||
|
||||
for (uint32_t i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
|
|
@ -263,15 +256,18 @@ panvk_pipeline_builder_init_shaders(struct panvk_pipeline_builder *builder,
|
|||
|
||||
/* Handle empty shaders gracefully */
|
||||
if (util_dynarray_num_elements(&builder->shaders[i]->binary, uint8_t)) {
|
||||
shader_ptr = pipeline->binary_bo->ptr.gpu +
|
||||
builder->stages[i].shader_offset;
|
||||
shader_ptr =
|
||||
pipeline->binary_bo->ptr.gpu + builder->stages[i].shader_offset;
|
||||
}
|
||||
|
||||
if (i != MESA_SHADER_FRAGMENT) {
|
||||
void *rsd = pipeline->state_bo->ptr.cpu + builder->stages[i].rsd_offset;
|
||||
mali_ptr gpu_rsd = pipeline->state_bo->ptr.gpu + builder->stages[i].rsd_offset;
|
||||
void *rsd =
|
||||
pipeline->state_bo->ptr.cpu + builder->stages[i].rsd_offset;
|
||||
mali_ptr gpu_rsd =
|
||||
pipeline->state_bo->ptr.gpu + builder->stages[i].rsd_offset;
|
||||
|
||||
panvk_per_arch(emit_non_fs_rsd)(builder->device, &shader->info, shader_ptr, rsd);
|
||||
panvk_per_arch(emit_non_fs_rsd)(builder->device, &shader->info,
|
||||
shader_ptr, rsd);
|
||||
pipeline->rsds[i] = gpu_rsd;
|
||||
}
|
||||
|
||||
|
|
@ -282,8 +278,10 @@ panvk_pipeline_builder_init_shaders(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
if (builder->create_info.gfx && !pipeline->fs.dynamic_rsd) {
|
||||
void *rsd = pipeline->state_bo->ptr.cpu + builder->stages[MESA_SHADER_FRAGMENT].rsd_offset;
|
||||
mali_ptr gpu_rsd = pipeline->state_bo->ptr.gpu + builder->stages[MESA_SHADER_FRAGMENT].rsd_offset;
|
||||
void *rsd = pipeline->state_bo->ptr.cpu +
|
||||
builder->stages[MESA_SHADER_FRAGMENT].rsd_offset;
|
||||
mali_ptr gpu_rsd = pipeline->state_bo->ptr.gpu +
|
||||
builder->stages[MESA_SHADER_FRAGMENT].rsd_offset;
|
||||
void *bd = rsd + pan_size(RENDERER_STATE);
|
||||
|
||||
panvk_per_arch(emit_base_fs_rsd)(builder->device, pipeline, rsd);
|
||||
|
|
@ -294,19 +292,19 @@ panvk_pipeline_builder_init_shaders(struct panvk_pipeline_builder *builder,
|
|||
|
||||
pipeline->rsds[MESA_SHADER_FRAGMENT] = gpu_rsd;
|
||||
} else if (builder->create_info.gfx) {
|
||||
panvk_per_arch(emit_base_fs_rsd)(builder->device, pipeline, &pipeline->fs.rsd_template);
|
||||
for (unsigned rt = 0; rt < MAX2(pipeline->blend.state.rt_count, 1); rt++) {
|
||||
panvk_per_arch(emit_base_fs_rsd)(builder->device, pipeline,
|
||||
&pipeline->fs.rsd_template);
|
||||
for (unsigned rt = 0; rt < MAX2(pipeline->blend.state.rt_count, 1);
|
||||
rt++) {
|
||||
panvk_per_arch(emit_blend)(builder->device, pipeline, rt,
|
||||
&pipeline->blend.bd_template[rt]);
|
||||
}
|
||||
}
|
||||
|
||||
pipeline->num_ubos = PANVK_NUM_BUILTIN_UBOS +
|
||||
builder->layout->num_ubos +
|
||||
pipeline->num_ubos = PANVK_NUM_BUILTIN_UBOS + builder->layout->num_ubos +
|
||||
builder->layout->num_dyn_ubos;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_parse_viewport(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
|
|
@ -321,17 +319,18 @@ panvk_pipeline_builder_parse_viewport(struct panvk_pipeline_builder *builder,
|
|||
panvk_pipeline_static_state(pipeline, VK_DYNAMIC_STATE_VIEWPORT) &&
|
||||
panvk_pipeline_static_state(pipeline, VK_DYNAMIC_STATE_SCISSOR)) {
|
||||
void *vpd = pipeline->state_bo->ptr.cpu + builder->vpd_offset;
|
||||
panvk_per_arch(emit_viewport)(builder->create_info.gfx->pViewportState->pViewports,
|
||||
builder->create_info.gfx->pViewportState->pScissors,
|
||||
vpd);
|
||||
pipeline->vpd = pipeline->state_bo->ptr.gpu +
|
||||
builder->vpd_offset;
|
||||
panvk_per_arch(emit_viewport)(
|
||||
builder->create_info.gfx->pViewportState->pViewports,
|
||||
builder->create_info.gfx->pViewportState->pScissors, vpd);
|
||||
pipeline->vpd = pipeline->state_bo->ptr.gpu + builder->vpd_offset;
|
||||
}
|
||||
if (panvk_pipeline_static_state(pipeline, VK_DYNAMIC_STATE_VIEWPORT))
|
||||
pipeline->viewport = builder->create_info.gfx->pViewportState->pViewports[0];
|
||||
pipeline->viewport =
|
||||
builder->create_info.gfx->pViewportState->pViewports[0];
|
||||
|
||||
if (panvk_pipeline_static_state(pipeline, VK_DYNAMIC_STATE_SCISSOR))
|
||||
pipeline->scissor = builder->create_info.gfx->pViewportState->pScissors[0];
|
||||
pipeline->scissor =
|
||||
builder->create_info.gfx->pViewportState->pScissors[0];
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -354,7 +353,6 @@ panvk_pipeline_builder_parse_dynamic(struct panvk_pipeline_builder *builder,
|
|||
unreachable("unsupported dynamic state");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static enum mali_draw_mode
|
||||
|
|
@ -384,36 +382,53 @@ translate_prim_topology(VkPrimitiveTopology in)
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_parse_input_assembly(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
panvk_pipeline_builder_parse_input_assembly(
|
||||
struct panvk_pipeline_builder *builder, struct panvk_pipeline *pipeline)
|
||||
{
|
||||
pipeline->ia.primitive_restart =
|
||||
builder->create_info.gfx->pInputAssemblyState->primitiveRestartEnable;
|
||||
pipeline->ia.topology =
|
||||
translate_prim_topology(builder->create_info.gfx->pInputAssemblyState->topology);
|
||||
pipeline->ia.topology = translate_prim_topology(
|
||||
builder->create_info.gfx->pInputAssemblyState->topology);
|
||||
}
|
||||
|
||||
static enum pipe_logicop
|
||||
translate_logicop(VkLogicOp in)
|
||||
{
|
||||
switch (in) {
|
||||
case VK_LOGIC_OP_CLEAR: return PIPE_LOGICOP_CLEAR;
|
||||
case VK_LOGIC_OP_AND: return PIPE_LOGICOP_AND;
|
||||
case VK_LOGIC_OP_AND_REVERSE: return PIPE_LOGICOP_AND_REVERSE;
|
||||
case VK_LOGIC_OP_COPY: return PIPE_LOGICOP_COPY;
|
||||
case VK_LOGIC_OP_AND_INVERTED: return PIPE_LOGICOP_AND_INVERTED;
|
||||
case VK_LOGIC_OP_NO_OP: return PIPE_LOGICOP_NOOP;
|
||||
case VK_LOGIC_OP_XOR: return PIPE_LOGICOP_XOR;
|
||||
case VK_LOGIC_OP_OR: return PIPE_LOGICOP_OR;
|
||||
case VK_LOGIC_OP_NOR: return PIPE_LOGICOP_NOR;
|
||||
case VK_LOGIC_OP_EQUIVALENT: return PIPE_LOGICOP_EQUIV;
|
||||
case VK_LOGIC_OP_INVERT: return PIPE_LOGICOP_INVERT;
|
||||
case VK_LOGIC_OP_OR_REVERSE: return PIPE_LOGICOP_OR_REVERSE;
|
||||
case VK_LOGIC_OP_COPY_INVERTED: return PIPE_LOGICOP_COPY_INVERTED;
|
||||
case VK_LOGIC_OP_OR_INVERTED: return PIPE_LOGICOP_OR_INVERTED;
|
||||
case VK_LOGIC_OP_NAND: return PIPE_LOGICOP_NAND;
|
||||
case VK_LOGIC_OP_SET: return PIPE_LOGICOP_SET;
|
||||
default: unreachable("Invalid logicop");
|
||||
case VK_LOGIC_OP_CLEAR:
|
||||
return PIPE_LOGICOP_CLEAR;
|
||||
case VK_LOGIC_OP_AND:
|
||||
return PIPE_LOGICOP_AND;
|
||||
case VK_LOGIC_OP_AND_REVERSE:
|
||||
return PIPE_LOGICOP_AND_REVERSE;
|
||||
case VK_LOGIC_OP_COPY:
|
||||
return PIPE_LOGICOP_COPY;
|
||||
case VK_LOGIC_OP_AND_INVERTED:
|
||||
return PIPE_LOGICOP_AND_INVERTED;
|
||||
case VK_LOGIC_OP_NO_OP:
|
||||
return PIPE_LOGICOP_NOOP;
|
||||
case VK_LOGIC_OP_XOR:
|
||||
return PIPE_LOGICOP_XOR;
|
||||
case VK_LOGIC_OP_OR:
|
||||
return PIPE_LOGICOP_OR;
|
||||
case VK_LOGIC_OP_NOR:
|
||||
return PIPE_LOGICOP_NOR;
|
||||
case VK_LOGIC_OP_EQUIVALENT:
|
||||
return PIPE_LOGICOP_EQUIV;
|
||||
case VK_LOGIC_OP_INVERT:
|
||||
return PIPE_LOGICOP_INVERT;
|
||||
case VK_LOGIC_OP_OR_REVERSE:
|
||||
return PIPE_LOGICOP_OR_REVERSE;
|
||||
case VK_LOGIC_OP_COPY_INVERTED:
|
||||
return PIPE_LOGICOP_COPY_INVERTED;
|
||||
case VK_LOGIC_OP_OR_INVERTED:
|
||||
return PIPE_LOGICOP_OR_INVERTED;
|
||||
case VK_LOGIC_OP_NAND:
|
||||
return PIPE_LOGICOP_NAND;
|
||||
case VK_LOGIC_OP_SET:
|
||||
return PIPE_LOGICOP_SET;
|
||||
default:
|
||||
unreachable("Invalid logicop");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,12 +436,18 @@ static enum blend_func
|
|||
translate_blend_op(VkBlendOp in)
|
||||
{
|
||||
switch (in) {
|
||||
case VK_BLEND_OP_ADD: return BLEND_FUNC_ADD;
|
||||
case VK_BLEND_OP_SUBTRACT: return BLEND_FUNC_SUBTRACT;
|
||||
case VK_BLEND_OP_REVERSE_SUBTRACT: return BLEND_FUNC_REVERSE_SUBTRACT;
|
||||
case VK_BLEND_OP_MIN: return BLEND_FUNC_MIN;
|
||||
case VK_BLEND_OP_MAX: return BLEND_FUNC_MAX;
|
||||
default: unreachable("Invalid blend op");
|
||||
case VK_BLEND_OP_ADD:
|
||||
return BLEND_FUNC_ADD;
|
||||
case VK_BLEND_OP_SUBTRACT:
|
||||
return BLEND_FUNC_SUBTRACT;
|
||||
case VK_BLEND_OP_REVERSE_SUBTRACT:
|
||||
return BLEND_FUNC_REVERSE_SUBTRACT;
|
||||
case VK_BLEND_OP_MIN:
|
||||
return BLEND_FUNC_MIN;
|
||||
case VK_BLEND_OP_MAX:
|
||||
return BLEND_FUNC_MAX;
|
||||
default:
|
||||
unreachable("Invalid blend op");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +484,8 @@ translate_blend_factor(VkBlendFactor in, bool dest_has_alpha)
|
|||
return BLEND_FACTOR_SRC1_ALPHA;
|
||||
case VK_BLEND_FACTOR_SRC_ALPHA_SATURATE:
|
||||
return BLEND_FACTOR_SRC_ALPHA_SATURATE;
|
||||
default: unreachable("Invalid blend factor");
|
||||
default:
|
||||
unreachable("Invalid blend factor");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -527,7 +549,8 @@ panvk_pipeline_builder_parse_color_blend(struct panvk_pipeline_builder *builder,
|
|||
builder->create_info.gfx->pColorBlendState->logicOpEnable;
|
||||
pipeline->blend.state.logicop_func =
|
||||
translate_logicop(builder->create_info.gfx->pColorBlendState->logicOp);
|
||||
pipeline->blend.state.rt_count = util_last_bit(builder->active_color_attachments);
|
||||
pipeline->blend.state.rt_count =
|
||||
util_last_bit(builder->active_color_attachments);
|
||||
memcpy(pipeline->blend.state.constants,
|
||||
builder->create_info.gfx->pColorBlendState->blendConstants,
|
||||
sizeof(pipeline->blend.state.constants));
|
||||
|
|
@ -541,25 +564,35 @@ panvk_pipeline_builder_parse_color_blend(struct panvk_pipeline_builder *builder,
|
|||
|
||||
bool dest_has_alpha = util_format_has_alpha(out->format);
|
||||
|
||||
out->nr_samples = builder->create_info.gfx->pMultisampleState->rasterizationSamples;
|
||||
out->nr_samples =
|
||||
builder->create_info.gfx->pMultisampleState->rasterizationSamples;
|
||||
out->equation.blend_enable = in->blendEnable;
|
||||
out->equation.color_mask = in->colorWriteMask;
|
||||
out->equation.rgb_func = translate_blend_op(in->colorBlendOp);
|
||||
out->equation.rgb_src_factor = translate_blend_factor(in->srcColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_invert_src_factor = inverted_blend_factor(in->srcColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_dst_factor = translate_blend_factor(in->dstColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_invert_dst_factor = inverted_blend_factor(in->dstColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_src_factor =
|
||||
translate_blend_factor(in->srcColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_invert_src_factor =
|
||||
inverted_blend_factor(in->srcColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_dst_factor =
|
||||
translate_blend_factor(in->dstColorBlendFactor, dest_has_alpha);
|
||||
out->equation.rgb_invert_dst_factor =
|
||||
inverted_blend_factor(in->dstColorBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_func = translate_blend_op(in->alphaBlendOp);
|
||||
out->equation.alpha_src_factor = translate_blend_factor(in->srcAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_invert_src_factor = inverted_blend_factor(in->srcAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_dst_factor = translate_blend_factor(in->dstAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_invert_dst_factor = inverted_blend_factor(in->dstAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_src_factor =
|
||||
translate_blend_factor(in->srcAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_invert_src_factor =
|
||||
inverted_blend_factor(in->srcAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_dst_factor =
|
||||
translate_blend_factor(in->dstAlphaBlendFactor, dest_has_alpha);
|
||||
out->equation.alpha_invert_dst_factor =
|
||||
inverted_blend_factor(in->dstAlphaBlendFactor, dest_has_alpha);
|
||||
|
||||
pipeline->blend.reads_dest |= pan_blend_reads_dest(out->equation);
|
||||
|
||||
unsigned constant_mask =
|
||||
panvk_per_arch(blend_needs_lowering)(pdev, &pipeline->blend.state, i) ?
|
||||
0 : pan_blend_constant_mask(out->equation);
|
||||
panvk_per_arch(blend_needs_lowering)(pdev, &pipeline->blend.state, i)
|
||||
? 0
|
||||
: pan_blend_constant_mask(out->equation);
|
||||
pipeline->blend.constant[i].index = ffs(constant_mask) - 1;
|
||||
if (constant_mask) {
|
||||
/* On Bifrost, the blend constant is expressed with a UNORM of the
|
||||
|
|
@ -574,8 +607,8 @@ panvk_pipeline_builder_parse_color_blend(struct panvk_pipeline_builder *builder,
|
|||
unsigned chan_size = 0;
|
||||
for (unsigned c = 0; c < format_desc->nr_channels; c++)
|
||||
chan_size = MAX2(format_desc->channel[c].size, chan_size);
|
||||
pipeline->blend.constant[i].bifrost_factor =
|
||||
((1 << chan_size) - 1) << (16 - chan_size);
|
||||
pipeline->blend.constant[i].bifrost_factor = ((1 << chan_size) - 1)
|
||||
<< (16 - chan_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -584,31 +617,43 @@ static void
|
|||
panvk_pipeline_builder_parse_multisample(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
{
|
||||
unsigned nr_samples =
|
||||
MAX2(builder->create_info.gfx->pMultisampleState->rasterizationSamples, 1);
|
||||
unsigned nr_samples = MAX2(
|
||||
builder->create_info.gfx->pMultisampleState->rasterizationSamples, 1);
|
||||
|
||||
pipeline->ms.rast_samples =
|
||||
builder->create_info.gfx->pMultisampleState->rasterizationSamples;
|
||||
pipeline->ms.sample_mask =
|
||||
builder->create_info.gfx->pMultisampleState->pSampleMask ?
|
||||
builder->create_info.gfx->pMultisampleState->pSampleMask[0] : UINT16_MAX;
|
||||
builder->create_info.gfx->pMultisampleState->pSampleMask
|
||||
? builder->create_info.gfx->pMultisampleState->pSampleMask[0]
|
||||
: UINT16_MAX;
|
||||
pipeline->ms.min_samples =
|
||||
MAX2(builder->create_info.gfx->pMultisampleState->minSampleShading * nr_samples, 1);
|
||||
MAX2(builder->create_info.gfx->pMultisampleState->minSampleShading *
|
||||
nr_samples,
|
||||
1);
|
||||
}
|
||||
|
||||
static enum mali_stencil_op
|
||||
translate_stencil_op(VkStencilOp in)
|
||||
{
|
||||
switch (in) {
|
||||
case VK_STENCIL_OP_KEEP: return MALI_STENCIL_OP_KEEP;
|
||||
case VK_STENCIL_OP_ZERO: return MALI_STENCIL_OP_ZERO;
|
||||
case VK_STENCIL_OP_REPLACE: return MALI_STENCIL_OP_REPLACE;
|
||||
case VK_STENCIL_OP_INCREMENT_AND_CLAMP: return MALI_STENCIL_OP_INCR_SAT;
|
||||
case VK_STENCIL_OP_DECREMENT_AND_CLAMP: return MALI_STENCIL_OP_DECR_SAT;
|
||||
case VK_STENCIL_OP_INCREMENT_AND_WRAP: return MALI_STENCIL_OP_INCR_WRAP;
|
||||
case VK_STENCIL_OP_DECREMENT_AND_WRAP: return MALI_STENCIL_OP_DECR_WRAP;
|
||||
case VK_STENCIL_OP_INVERT: return MALI_STENCIL_OP_INVERT;
|
||||
default: unreachable("Invalid stencil op");
|
||||
case VK_STENCIL_OP_KEEP:
|
||||
return MALI_STENCIL_OP_KEEP;
|
||||
case VK_STENCIL_OP_ZERO:
|
||||
return MALI_STENCIL_OP_ZERO;
|
||||
case VK_STENCIL_OP_REPLACE:
|
||||
return MALI_STENCIL_OP_REPLACE;
|
||||
case VK_STENCIL_OP_INCREMENT_AND_CLAMP:
|
||||
return MALI_STENCIL_OP_INCR_SAT;
|
||||
case VK_STENCIL_OP_DECREMENT_AND_CLAMP:
|
||||
return MALI_STENCIL_OP_DECR_SAT;
|
||||
case VK_STENCIL_OP_INCREMENT_AND_WRAP:
|
||||
return MALI_STENCIL_OP_INCR_WRAP;
|
||||
case VK_STENCIL_OP_DECREMENT_AND_WRAP:
|
||||
return MALI_STENCIL_OP_DECR_WRAP;
|
||||
case VK_STENCIL_OP_INVERT:
|
||||
return MALI_STENCIL_OP_INVERT;
|
||||
default:
|
||||
unreachable("Invalid stencil op");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -619,7 +664,8 @@ panvk_pipeline_builder_parse_zs(struct panvk_pipeline_builder *builder,
|
|||
if (!builder->use_depth_stencil_attachment)
|
||||
return;
|
||||
|
||||
pipeline->zs.z_test = builder->create_info.gfx->pDepthStencilState->depthTestEnable;
|
||||
pipeline->zs.z_test =
|
||||
builder->create_info.gfx->pDepthStencilState->depthTestEnable;
|
||||
|
||||
/* The Vulkan spec says:
|
||||
*
|
||||
|
|
@ -630,34 +676,36 @@ panvk_pipeline_builder_parse_zs(struct panvk_pipeline_builder *builder,
|
|||
* The hardware does not make this distinction, though, so we AND in the
|
||||
* condition ourselves.
|
||||
*/
|
||||
pipeline->zs.z_write = pipeline->zs.z_test &&
|
||||
pipeline->zs.z_write =
|
||||
pipeline->zs.z_test &&
|
||||
builder->create_info.gfx->pDepthStencilState->depthWriteEnable;
|
||||
|
||||
pipeline->zs.z_compare_func =
|
||||
panvk_per_arch(translate_compare_func)(builder->create_info.gfx->pDepthStencilState->depthCompareOp);
|
||||
pipeline->zs.s_test = builder->create_info.gfx->pDepthStencilState->stencilTestEnable;
|
||||
pipeline->zs.s_front.fail_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->front.failOp);
|
||||
pipeline->zs.s_front.pass_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->front.passOp);
|
||||
pipeline->zs.s_front.z_fail_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->front.depthFailOp);
|
||||
pipeline->zs.s_front.compare_func =
|
||||
panvk_per_arch(translate_compare_func)(builder->create_info.gfx->pDepthStencilState->front.compareOp);
|
||||
pipeline->zs.z_compare_func = panvk_per_arch(translate_compare_func)(
|
||||
builder->create_info.gfx->pDepthStencilState->depthCompareOp);
|
||||
pipeline->zs.s_test =
|
||||
builder->create_info.gfx->pDepthStencilState->stencilTestEnable;
|
||||
pipeline->zs.s_front.fail_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->front.failOp);
|
||||
pipeline->zs.s_front.pass_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->front.passOp);
|
||||
pipeline->zs.s_front.z_fail_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->front.depthFailOp);
|
||||
pipeline->zs.s_front.compare_func = panvk_per_arch(translate_compare_func)(
|
||||
builder->create_info.gfx->pDepthStencilState->front.compareOp);
|
||||
pipeline->zs.s_front.compare_mask =
|
||||
builder->create_info.gfx->pDepthStencilState->front.compareMask;
|
||||
pipeline->zs.s_front.write_mask =
|
||||
builder->create_info.gfx->pDepthStencilState->front.writeMask;
|
||||
pipeline->zs.s_front.ref =
|
||||
builder->create_info.gfx->pDepthStencilState->front.reference;
|
||||
pipeline->zs.s_back.fail_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->back.failOp);
|
||||
pipeline->zs.s_back.pass_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->back.passOp);
|
||||
pipeline->zs.s_back.z_fail_op =
|
||||
translate_stencil_op(builder->create_info.gfx->pDepthStencilState->back.depthFailOp);
|
||||
pipeline->zs.s_back.compare_func =
|
||||
panvk_per_arch(translate_compare_func)(builder->create_info.gfx->pDepthStencilState->back.compareOp);
|
||||
pipeline->zs.s_back.fail_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->back.failOp);
|
||||
pipeline->zs.s_back.pass_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->back.passOp);
|
||||
pipeline->zs.s_back.z_fail_op = translate_stencil_op(
|
||||
builder->create_info.gfx->pDepthStencilState->back.depthFailOp);
|
||||
pipeline->zs.s_back.compare_func = panvk_per_arch(translate_compare_func)(
|
||||
builder->create_info.gfx->pDepthStencilState->back.compareOp);
|
||||
pipeline->zs.s_back.compare_mask =
|
||||
builder->create_info.gfx->pDepthStencilState->back.compareMask;
|
||||
pipeline->zs.s_back.write_mask =
|
||||
|
|
@ -670,17 +718,29 @@ static void
|
|||
panvk_pipeline_builder_parse_rast(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
{
|
||||
pipeline->rast.clamp_depth = builder->create_info.gfx->pRasterizationState->depthClampEnable;
|
||||
pipeline->rast.depth_bias.enable = builder->create_info.gfx->pRasterizationState->depthBiasEnable;
|
||||
pipeline->rast.clamp_depth =
|
||||
builder->create_info.gfx->pRasterizationState->depthClampEnable;
|
||||
pipeline->rast.depth_bias.enable =
|
||||
builder->create_info.gfx->pRasterizationState->depthBiasEnable;
|
||||
pipeline->rast.depth_bias.constant_factor =
|
||||
builder->create_info.gfx->pRasterizationState->depthBiasConstantFactor;
|
||||
pipeline->rast.depth_bias.clamp = builder->create_info.gfx->pRasterizationState->depthBiasClamp;
|
||||
pipeline->rast.depth_bias.slope_factor = builder->create_info.gfx->pRasterizationState->depthBiasSlopeFactor;
|
||||
pipeline->rast.front_ccw = builder->create_info.gfx->pRasterizationState->frontFace == VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||
pipeline->rast.cull_front_face = builder->create_info.gfx->pRasterizationState->cullMode & VK_CULL_MODE_FRONT_BIT;
|
||||
pipeline->rast.cull_back_face = builder->create_info.gfx->pRasterizationState->cullMode & VK_CULL_MODE_BACK_BIT;
|
||||
pipeline->rast.line_width = builder->create_info.gfx->pRasterizationState->lineWidth;
|
||||
pipeline->rast.enable = !builder->create_info.gfx->pRasterizationState->rasterizerDiscardEnable;
|
||||
pipeline->rast.depth_bias.clamp =
|
||||
builder->create_info.gfx->pRasterizationState->depthBiasClamp;
|
||||
pipeline->rast.depth_bias.slope_factor =
|
||||
builder->create_info.gfx->pRasterizationState->depthBiasSlopeFactor;
|
||||
pipeline->rast.front_ccw =
|
||||
builder->create_info.gfx->pRasterizationState->frontFace ==
|
||||
VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||
pipeline->rast.cull_front_face =
|
||||
builder->create_info.gfx->pRasterizationState->cullMode &
|
||||
VK_CULL_MODE_FRONT_BIT;
|
||||
pipeline->rast.cull_back_face =
|
||||
builder->create_info.gfx->pRasterizationState->cullMode &
|
||||
VK_CULL_MODE_BACK_BIT;
|
||||
pipeline->rast.line_width =
|
||||
builder->create_info.gfx->pRasterizationState->lineWidth;
|
||||
pipeline->rast.enable =
|
||||
!builder->create_info.gfx->pRasterizationState->rasterizerDiscardEnable;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -692,24 +752,24 @@ panvk_fs_required(struct panvk_pipeline *pipeline)
|
|||
if (info->fs.sidefx)
|
||||
return true;
|
||||
|
||||
/* If colour is written we need to execute */
|
||||
const struct pan_blend_state *blend = &pipeline->blend.state;
|
||||
for (unsigned i = 0; i < blend->rt_count; ++i) {
|
||||
if (blend->rts[i].equation.color_mask)
|
||||
return true;
|
||||
}
|
||||
/* If colour is written we need to execute */
|
||||
const struct pan_blend_state *blend = &pipeline->blend.state;
|
||||
for (unsigned i = 0; i < blend->rt_count; ++i) {
|
||||
if (blend->rts[i].equation.color_mask)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If depth is written and not implied we need to execute.
|
||||
* TODO: Predicate on Z/S writes being enabled */
|
||||
return (info->fs.writes_depth || info->fs.writes_stencil);
|
||||
/* If depth is written and not implied we need to execute.
|
||||
* TODO: Predicate on Z/S writes being enabled */
|
||||
return (info->fs.writes_depth || info->fs.writes_stencil);
|
||||
}
|
||||
|
||||
#define PANVK_DYNAMIC_FS_RSD_MASK \
|
||||
((1 << VK_DYNAMIC_STATE_DEPTH_BIAS) | \
|
||||
(1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE))
|
||||
#define PANVK_DYNAMIC_FS_RSD_MASK \
|
||||
((1 << VK_DYNAMIC_STATE_DEPTH_BIAS) | \
|
||||
(1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) | \
|
||||
(1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE))
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_init_fs_state(struct panvk_pipeline_builder *builder,
|
||||
|
|
@ -781,14 +841,12 @@ panvk_pipeline_builder_collect_varyings(struct panvk_pipeline_builder *builder,
|
|||
|
||||
for (unsigned i = 0; i < info->varyings.input_count; i++) {
|
||||
panvk_pipeline_update_varying_slot(&pipeline->varyings, s,
|
||||
&info->varyings.input[i],
|
||||
true);
|
||||
&info->varyings.input[i], true);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < info->varyings.output_count; i++) {
|
||||
panvk_pipeline_update_varying_slot(&pipeline->varyings, s,
|
||||
&info->varyings.output[i],
|
||||
false);
|
||||
&info->varyings.output[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -810,8 +868,8 @@ panvk_pipeline_builder_collect_varyings(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
panvk_pipeline_builder_parse_vertex_input(
|
||||
struct panvk_pipeline_builder *builder, struct panvk_pipeline *pipeline)
|
||||
{
|
||||
struct panvk_attribs_info *attribs = &pipeline->attribs;
|
||||
const VkPipelineVertexInputStateCreateInfo *info =
|
||||
|
|
@ -848,12 +906,11 @@ panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder
|
|||
&info->pVertexAttributeDescriptions[i];
|
||||
|
||||
unsigned attrib = desc->location + VERT_ATTRIB_GENERIC0;
|
||||
unsigned slot = util_bitcount64(vs->attributes_read &
|
||||
BITFIELD64_MASK(attrib));
|
||||
unsigned slot =
|
||||
util_bitcount64(vs->attributes_read & BITFIELD64_MASK(attrib));
|
||||
|
||||
attribs->attrib[slot].buf = desc->binding;
|
||||
attribs->attrib[slot].format =
|
||||
vk_format_to_pipe_format(desc->format);
|
||||
attribs->attrib[slot].format = vk_format_to_pipe_format(desc->format);
|
||||
attribs->attrib[slot].offset = desc->offset;
|
||||
}
|
||||
|
||||
|
|
@ -909,15 +966,15 @@ panvk_pipeline_builder_build(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_init_graphics(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_device *dev,
|
||||
struct panvk_pipeline_cache *cache,
|
||||
const VkGraphicsPipelineCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc)
|
||||
panvk_pipeline_builder_init_graphics(
|
||||
struct panvk_pipeline_builder *builder, struct panvk_device *dev,
|
||||
struct panvk_pipeline_cache *cache,
|
||||
const VkGraphicsPipelineCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_pipeline_layout, layout, create_info->layout);
|
||||
assert(layout);
|
||||
*builder = (struct panvk_pipeline_builder) {
|
||||
*builder = (struct panvk_pipeline_builder){
|
||||
.device = dev,
|
||||
.cache = cache,
|
||||
.layout = layout,
|
||||
|
|
@ -933,13 +990,16 @@ panvk_pipeline_builder_init_graphics(struct panvk_pipeline_builder *builder,
|
|||
} else {
|
||||
builder->samples = create_info->pMultisampleState->rasterizationSamples;
|
||||
|
||||
const struct panvk_render_pass *pass = panvk_render_pass_from_handle(create_info->renderPass);
|
||||
const struct panvk_subpass *subpass = &pass->subpasses[create_info->subpass];
|
||||
const struct panvk_render_pass *pass =
|
||||
panvk_render_pass_from_handle(create_info->renderPass);
|
||||
const struct panvk_subpass *subpass =
|
||||
&pass->subpasses[create_info->subpass];
|
||||
|
||||
builder->use_depth_stencil_attachment =
|
||||
subpass->zs_attachment.idx != VK_ATTACHMENT_UNUSED;
|
||||
|
||||
assert(subpass->color_count <= create_info->pColorBlendState->attachmentCount);
|
||||
assert(subpass->color_count <=
|
||||
create_info->pColorBlendState->attachmentCount);
|
||||
builder->active_color_attachments = 0;
|
||||
for (uint32_t i = 0; i < subpass->color_count; i++) {
|
||||
uint32_t idx = subpass->color_attachments[i].idx;
|
||||
|
|
@ -953,12 +1013,10 @@ panvk_pipeline_builder_init_graphics(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_per_arch(CreateGraphicsPipelines)(VkDevice device,
|
||||
VkPipelineCache pipelineCache,
|
||||
uint32_t count,
|
||||
const VkGraphicsPipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipelines)
|
||||
panvk_per_arch(CreateGraphicsPipelines)(
|
||||
VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
|
||||
const VkGraphicsPipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, dev, device);
|
||||
VK_FROM_HANDLE(panvk_pipeline_cache, cache, pipelineCache);
|
||||
|
|
@ -988,15 +1046,15 @@ panvk_per_arch(CreateGraphicsPipelines)(VkDevice device,
|
|||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_init_compute(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_device *dev,
|
||||
struct panvk_pipeline_cache *cache,
|
||||
const VkComputePipelineCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc)
|
||||
panvk_pipeline_builder_init_compute(
|
||||
struct panvk_pipeline_builder *builder, struct panvk_device *dev,
|
||||
struct panvk_pipeline_cache *cache,
|
||||
const VkComputePipelineCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_pipeline_layout, layout, create_info->layout);
|
||||
assert(layout);
|
||||
*builder = (struct panvk_pipeline_builder) {
|
||||
*builder = (struct panvk_pipeline_builder){
|
||||
.device = dev,
|
||||
.cache = cache,
|
||||
.layout = layout,
|
||||
|
|
@ -1006,12 +1064,10 @@ panvk_pipeline_builder_init_compute(struct panvk_pipeline_builder *builder,
|
|||
}
|
||||
|
||||
VkResult
|
||||
panvk_per_arch(CreateComputePipelines)(VkDevice device,
|
||||
VkPipelineCache pipelineCache,
|
||||
uint32_t count,
|
||||
const VkComputePipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipelines)
|
||||
panvk_per_arch(CreateComputePipelines)(
|
||||
VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
|
||||
const VkComputePipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, dev, device);
|
||||
VK_FROM_HANDLE(panvk_pipeline_cache, cache, pipelineCache);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@
|
|||
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "nir_builder.h"
|
||||
#include "nir_deref.h"
|
||||
#include "nir_lower_blend.h"
|
||||
#include "nir_conversion_builder.h"
|
||||
#include "spirv/nir_spirv.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "nir_builder.h"
|
||||
#include "nir_conversion_builder.h"
|
||||
#include "nir_deref.h"
|
||||
#include "nir_lower_blend.h"
|
||||
#include "vk_shader_module.h"
|
||||
|
||||
#include "compiler/bifrost_nir.h"
|
||||
|
|
@ -157,14 +157,18 @@ panvk_lower_blend(struct panfrost_device *pdev, nir_shader *nir,
|
|||
} else {
|
||||
options.rt[rt].rgb.func = rt_state->equation.rgb_func;
|
||||
options.rt[rt].rgb.src_factor = rt_state->equation.rgb_src_factor;
|
||||
options.rt[rt].rgb.invert_src_factor = rt_state->equation.rgb_invert_src_factor;
|
||||
options.rt[rt].rgb.invert_src_factor =
|
||||
rt_state->equation.rgb_invert_src_factor;
|
||||
options.rt[rt].rgb.dst_factor = rt_state->equation.rgb_dst_factor;
|
||||
options.rt[rt].rgb.invert_dst_factor = rt_state->equation.rgb_invert_dst_factor;
|
||||
options.rt[rt].rgb.invert_dst_factor =
|
||||
rt_state->equation.rgb_invert_dst_factor;
|
||||
options.rt[rt].alpha.func = rt_state->equation.alpha_func;
|
||||
options.rt[rt].alpha.src_factor = rt_state->equation.alpha_src_factor;
|
||||
options.rt[rt].alpha.invert_src_factor = rt_state->equation.alpha_invert_src_factor;
|
||||
options.rt[rt].alpha.invert_src_factor =
|
||||
rt_state->equation.alpha_invert_src_factor;
|
||||
options.rt[rt].alpha.dst_factor = rt_state->equation.alpha_dst_factor;
|
||||
options.rt[rt].alpha.invert_dst_factor = rt_state->equation.alpha_invert_dst_factor;
|
||||
options.rt[rt].alpha.invert_dst_factor =
|
||||
rt_state->equation.alpha_invert_dst_factor;
|
||||
}
|
||||
|
||||
/* Update the equation to force a color replacement */
|
||||
|
|
@ -199,15 +203,12 @@ panvk_lower_load_push_constant(nir_builder *b, nir_instr *instr, void *data)
|
|||
return false;
|
||||
|
||||
b->cursor = nir_before_instr(instr);
|
||||
nir_ssa_def *ubo_load =
|
||||
nir_load_ubo(b, nir_dest_num_components(intr->dest),
|
||||
nir_dest_bit_size(intr->dest),
|
||||
nir_imm_int(b, PANVK_PUSH_CONST_UBO_INDEX),
|
||||
intr->src[0].ssa,
|
||||
.align_mul = nir_dest_bit_size(intr->dest) / 8,
|
||||
.align_offset = 0,
|
||||
.range_base = nir_intrinsic_base(intr),
|
||||
.range = nir_intrinsic_range(intr));
|
||||
nir_ssa_def *ubo_load = nir_load_ubo(
|
||||
b, nir_dest_num_components(intr->dest), nir_dest_bit_size(intr->dest),
|
||||
nir_imm_int(b, PANVK_PUSH_CONST_UBO_INDEX), intr->src[0].ssa,
|
||||
.align_mul = nir_dest_bit_size(intr->dest) / 8, .align_offset = 0,
|
||||
.range_base = nir_intrinsic_base(intr),
|
||||
.range = nir_intrinsic_range(intr));
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa, ubo_load);
|
||||
nir_instr_remove(instr);
|
||||
return true;
|
||||
|
|
@ -218,16 +219,14 @@ shared_type_info(const struct glsl_type *type, unsigned *size, unsigned *align)
|
|||
{
|
||||
assert(glsl_type_is_vector_or_scalar(type));
|
||||
|
||||
uint32_t comp_size = glsl_type_is_boolean(type)
|
||||
? 4 : glsl_get_bit_size(type) / 8;
|
||||
uint32_t comp_size =
|
||||
glsl_type_is_boolean(type) ? 4 : glsl_get_bit_size(type) / 8;
|
||||
unsigned length = glsl_get_vector_elements(type);
|
||||
*size = comp_size * length,
|
||||
*align = comp_size * (length == 3 ? 4 : length);
|
||||
*size = comp_size * length, *align = comp_size * (length == 3 ? 4 : length);
|
||||
}
|
||||
|
||||
struct panvk_shader *
|
||||
panvk_per_arch(shader_create)(struct panvk_device *dev,
|
||||
gl_shader_stage stage,
|
||||
panvk_per_arch(shader_create)(struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
unsigned sysval_ubo,
|
||||
|
|
@ -248,29 +247,28 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
|
||||
/* TODO these are made-up */
|
||||
const struct spirv_to_nir_options spirv_options = {
|
||||
.caps = {
|
||||
.variable_pointers = true,
|
||||
},
|
||||
.caps =
|
||||
{
|
||||
.variable_pointers = true,
|
||||
},
|
||||
.ubo_addr_format = nir_address_format_32bit_index_offset,
|
||||
.ssbo_addr_format = dev->vk.enabled_features.robustBufferAccess ?
|
||||
nir_address_format_64bit_bounded_global :
|
||||
nir_address_format_64bit_global_32bit_offset,
|
||||
.ssbo_addr_format = dev->vk.enabled_features.robustBufferAccess
|
||||
? nir_address_format_64bit_bounded_global
|
||||
: nir_address_format_64bit_global_32bit_offset,
|
||||
};
|
||||
|
||||
nir_shader *nir;
|
||||
VkResult result = vk_shader_module_to_nir(&dev->vk, module, stage,
|
||||
stage_info->pName,
|
||||
stage_info->pSpecializationInfo,
|
||||
&spirv_options,
|
||||
GENX(pan_shader_get_compiler_options)(),
|
||||
NULL, &nir);
|
||||
VkResult result = vk_shader_module_to_nir(
|
||||
&dev->vk, module, stage, stage_info->pName,
|
||||
stage_info->pSpecializationInfo, &spirv_options,
|
||||
GENX(pan_shader_get_compiler_options)(), NULL, &nir);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free2(&dev->vk.alloc, alloc, shader);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_io_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, true);
|
||||
NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir),
|
||||
true, true);
|
||||
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
.gpu_id = pdev->gpu_id,
|
||||
|
|
@ -279,8 +277,7 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
};
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_indirect_derefs,
|
||||
nir_var_shader_in | nir_var_shader_out,
|
||||
UINT32_MAX);
|
||||
nir_var_shader_in | nir_var_shader_out, UINT32_MAX);
|
||||
|
||||
NIR_PASS_V(nir, nir_opt_copy_prop_vars);
|
||||
NIR_PASS_V(nir, nir_opt_combine_stores, nir_var_all);
|
||||
|
|
@ -318,33 +315,28 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
};
|
||||
NIR_PASS_V(nir, nir_lower_tex, &lower_tex_options);
|
||||
|
||||
NIR_PASS_V(nir, panvk_per_arch(nir_lower_descriptors),
|
||||
dev, layout, &shader->has_img_access);
|
||||
NIR_PASS_V(nir, panvk_per_arch(nir_lower_descriptors), dev, layout,
|
||||
&shader->has_img_access);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_ubo,
|
||||
nir_address_format_32bit_index_offset);
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_ssbo,
|
||||
spirv_options.ssbo_addr_format);
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io,
|
||||
nir_var_mem_push_const,
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_push_const,
|
||||
nir_address_format_32bit_offset);
|
||||
|
||||
if (gl_shader_stage_uses_workgroup(stage)) {
|
||||
if (!nir->info.shared_memory_explicit_layout) {
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
|
||||
nir_var_mem_shared,
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared,
|
||||
shared_type_info);
|
||||
}
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io,
|
||||
nir_var_mem_shared,
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared,
|
||||
nir_address_format_32bit_offset);
|
||||
}
|
||||
|
||||
NIR_PASS_V(nir, nir_shader_instructions_pass,
|
||||
panvk_lower_load_push_constant,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
NIR_PASS_V(nir, nir_shader_instructions_pass, panvk_lower_load_push_constant,
|
||||
nir_metadata_block_index | nir_metadata_dominance,
|
||||
(void *)layout);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_system_values);
|
||||
|
|
@ -354,7 +346,8 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
NIR_PASS_V(nir, nir_lower_var_copies);
|
||||
|
||||
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs, stage);
|
||||
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs, stage);
|
||||
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
|
||||
stage);
|
||||
|
||||
/* Needed to turn shader_temp into function_temp since the backend only
|
||||
* handles the latter for now.
|
||||
|
|
@ -362,7 +355,8 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
|
||||
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
if (unlikely(dev->physical_device->instance->debug_flags & PANVK_DEBUG_NIR)) {
|
||||
if (unlikely(dev->physical_device->instance->debug_flags &
|
||||
PANVK_DEBUG_NIR)) {
|
||||
fprintf(stderr, "translated nir:\n");
|
||||
nir_print_shader(nir, stderr);
|
||||
}
|
||||
|
|
@ -394,8 +388,8 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
|
|||
GENX(pan_shader_compile)(nir, &inputs, &shader->binary, &shader->info);
|
||||
|
||||
/* Patch the descriptor count */
|
||||
shader->info.ubo_count = PANVK_NUM_BUILTIN_UBOS +
|
||||
layout->num_ubos + layout->num_dyn_ubos;
|
||||
shader->info.ubo_count =
|
||||
PANVK_NUM_BUILTIN_UBOS + layout->num_ubos + layout->num_dyn_ubos;
|
||||
shader->info.sampler_count = layout->num_samplers;
|
||||
shader->info.texture_count = layout->num_textures;
|
||||
if (shader->has_img_access)
|
||||
|
|
|
|||
|
|
@ -110,11 +110,11 @@ panvk_varyings_buf_count(struct panvk_varyings_info *varyings)
|
|||
|
||||
static inline void
|
||||
panvk_varyings_alloc(struct panvk_varyings_info *varyings,
|
||||
struct pan_pool *varying_mem_pool,
|
||||
unsigned vertex_count)
|
||||
struct pan_pool *varying_mem_pool, unsigned vertex_count)
|
||||
{
|
||||
for (unsigned i = 0; i < PANVK_VARY_BUF_MAX; i++) {
|
||||
if (!(varyings->buf_mask & (1 << i))) continue;
|
||||
if (!(varyings->buf_mask & (1 << i)))
|
||||
continue;
|
||||
|
||||
unsigned buf_idx = panvk_varying_buf_index(varyings, i);
|
||||
unsigned size = varyings->buf[buf_idx].stride * vertex_count;
|
||||
|
|
|
|||
|
|
@ -42,12 +42,11 @@ panvk_wsi_init(struct panvk_physical_device *physical_device)
|
|||
{
|
||||
VkResult result;
|
||||
|
||||
result = wsi_device_init(&physical_device->wsi_device,
|
||||
panvk_physical_device_to_handle(physical_device),
|
||||
panvk_wsi_proc_addr,
|
||||
&physical_device->instance->vk.alloc,
|
||||
physical_device->master_fd, NULL,
|
||||
&(struct wsi_device_options){.sw_device = false});
|
||||
result = wsi_device_init(
|
||||
&physical_device->wsi_device,
|
||||
panvk_physical_device_to_handle(physical_device), panvk_wsi_proc_addr,
|
||||
&physical_device->instance->vk.alloc, physical_device->master_fd, NULL,
|
||||
&(struct wsi_device_options){.sw_device = false});
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue