mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2024-12-01 13:24:20 +01:00
cmdclear now only flags image for clearing
actual clear happens in pipelinebarrier
This commit is contained in:
parent
356c7d3277
commit
0c3e0f798b
213
driver/driver.c
213
driver/driver.c
@ -1376,48 +1376,89 @@ VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
|
|||||||
{
|
{
|
||||||
assert(commandBuffer);
|
assert(commandBuffer);
|
||||||
|
|
||||||
|
//TODO pipeline stage flags
|
||||||
|
//VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
|
||||||
|
//VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
|
||||||
|
//VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
|
||||||
|
//VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
|
||||||
|
//VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
|
||||||
|
//VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
|
||||||
|
//VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_TRANSFER_BIT
|
||||||
|
//VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
|
||||||
|
//VK_PIPELINE_STAGE_HOST_BIT
|
||||||
|
//VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT
|
||||||
|
//VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
|
||||||
|
|
||||||
|
//TODO dependency flags
|
||||||
|
//VK_DEPENDENCY_BY_REGION_BIT,
|
||||||
|
//VK_DEPENDENCY_DEVICE_GROUP_BIT,
|
||||||
|
//VK_DEPENDENCY_VIEW_LOCAL_BIT
|
||||||
|
|
||||||
|
//TODO access flags
|
||||||
|
//VK_ACCESS_INDIRECT_COMMAND_READ_BIT
|
||||||
|
//VK_ACCESS_INDEX_READ_BIT
|
||||||
|
//VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
|
||||||
|
//VK_ACCESS_UNIFORM_READ_BIT
|
||||||
|
//VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
|
||||||
|
//VK_ACCESS_SHADER_READ_BIT
|
||||||
|
//VK_ACCESS_SHADER_WRITE_BIT
|
||||||
|
//VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
|
||||||
|
//VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
|
||||||
|
//VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
|
||||||
|
//VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
|
||||||
|
//VK_ACCESS_TRANSFER_READ_BIT
|
||||||
|
//VK_ACCESS_TRANSFER_WRITE_BIT
|
||||||
|
//VK_ACCESS_HOST_READ_BIT
|
||||||
|
//VK_ACCESS_HOST_WRITE_BIT
|
||||||
|
//VK_ACCESS_MEMORY_READ_BIT
|
||||||
|
//VK_ACCESS_MEMORY_WRITE_BIT
|
||||||
|
//VK_ACCESS_COMMAND_PROCESS_READ_BIT_NVX
|
||||||
|
//VK_ACCESS_COMMAND_PROCESS_WRITE_BIT_NVX
|
||||||
|
|
||||||
|
//TODO Layout transition flags
|
||||||
|
//VK_IMAGE_LAYOUT_UNDEFINED
|
||||||
|
//VK_IMAGE_LAYOUT_GENERAL
|
||||||
|
//VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_PREINITIALIZED
|
||||||
|
//VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
|
||||||
|
//VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
|
||||||
|
//VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR
|
||||||
|
|
||||||
|
for(int c = 0; c < memoryBarrierCount; ++c)
|
||||||
|
{
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
for(int c = 0; c < bufferMemoryBarrierCount; ++c)
|
||||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdClearColorImage
|
{
|
||||||
* Color and depth/stencil images can be cleared outside a render pass instance using vkCmdClearColorImage or vkCmdClearDepthStencilImage, respectively.
|
//TODO
|
||||||
* These commands are only allowed outside of a render pass instance.
|
}
|
||||||
*/
|
|
||||||
VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
|
||||||
VkCommandBuffer commandBuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageLayout imageLayout,
|
|
||||||
const VkClearColorValue* pColor,
|
|
||||||
uint32_t rangeCount,
|
|
||||||
const VkImageSubresourceRange* pRanges)
|
|
||||||
{
|
|
||||||
assert(commandBuffer);
|
|
||||||
assert(image);
|
|
||||||
assert(pColor);
|
|
||||||
|
|
||||||
//TODO this should only flag an image for clearing. This can only be called outside a renderpass
|
for(int c = 0; c < imageMemoryBarrierCount; ++c)
|
||||||
//actual clearing would only happen:
|
{
|
||||||
// -if image is rendered to (insert clear before first draw call)
|
_image* i = pImageMemoryBarriers[c].image;
|
||||||
// -if the image is bound for sampling (submit a CL with a clear)
|
|
||||||
// -if the command buffer is closed without any rendering (insert clear)
|
|
||||||
// -etc.
|
|
||||||
//we shouldn't clear an image if noone uses it
|
|
||||||
|
|
||||||
//TODO ranges support
|
assert(i->layout == pImageMemoryBarriers[c].oldLayout || i->layout == VK_IMAGE_LAYOUT_UNDEFINED);
|
||||||
|
|
||||||
assert(imageLayout == VK_IMAGE_LAYOUT_GENERAL ||
|
if(srcStageMask & VK_PIPELINE_STAGE_TRANSFER_BIT &&
|
||||||
imageLayout == VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR ||
|
pImageMemoryBarriers[c].srcAccessMask & VK_ACCESS_TRANSFER_WRITE_BIT &&
|
||||||
imageLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
i->needToClear)
|
||||||
|
{
|
||||||
|
//insert CRs to clear the image
|
||||||
|
|
||||||
assert(commandBuffer->state == CMDBUF_STATE_RECORDING);
|
assert(i->layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
assert(_queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT || _queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_COMPUTE_BIT);
|
|
||||||
|
|
||||||
//TODO externally sync cmdbuf, cmdpool
|
|
||||||
|
|
||||||
_image* i = image;
|
|
||||||
|
|
||||||
assert(i->usageBits & VK_IMAGE_USAGE_TRANSFER_DST_BIT);
|
|
||||||
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_TILE_BINNING_MODE_CONFIGURATION_length);
|
clFit(commandBuffer, &commandBuffer->binCl, V3D21_TILE_BINNING_MODE_CONFIGURATION_length);
|
||||||
clInsertTileBinningModeConfiguration(&commandBuffer->binCl,
|
clInsertTileBinningModeConfiguration(&commandBuffer->binCl,
|
||||||
@ -1452,10 +1493,9 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
|||||||
VC4_SET_FIELD(VC4_RENDER_CONFIG_FORMAT_RGBA8888, VC4_RENDER_CONFIG_FORMAT) |
|
VC4_SET_FIELD(VC4_RENDER_CONFIG_FORMAT_RGBA8888, VC4_RENDER_CONFIG_FORMAT) |
|
||||||
VC4_SET_FIELD(i->tiling, VC4_RENDER_CONFIG_MEMORY_FORMAT);
|
VC4_SET_FIELD(i->tiling, VC4_RENDER_CONFIG_MEMORY_FORMAT);
|
||||||
|
|
||||||
//TODO msaa?
|
commandBuffer->submitCl.clear_color[0] = i->clearColor[0];
|
||||||
|
commandBuffer->submitCl.clear_color[1] = i->clearColor[1];
|
||||||
|
|
||||||
commandBuffer->submitCl.clear_color[0] =
|
|
||||||
commandBuffer->submitCl.clear_color[1] = packVec4IntoABGR8(pColor->float32);
|
|
||||||
//TODO ranges
|
//TODO ranges
|
||||||
commandBuffer->submitCl.min_x_tile = 0;
|
commandBuffer->submitCl.min_x_tile = 0;
|
||||||
commandBuffer->submitCl.min_y_tile = 0;
|
commandBuffer->submitCl.min_y_tile = 0;
|
||||||
@ -1484,58 +1524,55 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
|||||||
commandBuffer->submitCl.flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
commandBuffer->submitCl.flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
||||||
commandBuffer->submitCl.clear_z = 0; //TODO
|
commandBuffer->submitCl.clear_z = 0; //TODO
|
||||||
commandBuffer->submitCl.clear_s = 0;
|
commandBuffer->submitCl.clear_s = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO primitive list format must be followed by shader state
|
//transition to new layout
|
||||||
//clFit(commandBuffer, &commandBuffer->binCl, V3D21_GL_SHADER_STATE_length);
|
i->layout = pImageMemoryBarriers[c].newLayout;
|
||||||
//clInsertShaderState(&commandBuffer->binCl, 0, 0, 0);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//clFit(commandBuffer, &commandBuffer->binCl, V3D21_CLIP_WINDOW_length);
|
/*
|
||||||
//clInsertClipWindow(&commandBuffer->binCl, i->width, i->height, 0, 0); //TODO should this be configurable?
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdClearColorImage
|
||||||
|
* Color and depth/stencil images can be cleared outside a render pass instance using vkCmdClearColorImage or vkCmdClearDepthStencilImage, respectively.
|
||||||
/*
|
* These commands are only allowed outside of a render pass instance.
|
||||||
//TODO
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_CONFIGURATION_BITS_length);
|
|
||||||
clInsertConfigurationBits(&commandBuffer->binCl,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
V3D_COMPARE_FUNC_ALWAYS,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1);
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_DEPTH_OFFSET_length);
|
|
||||||
clInsertDepthOffset(&commandBuffer->binCl, 0, 0);
|
|
||||||
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_POINT_SIZE_length);
|
|
||||||
clInsertPointSize(&commandBuffer->binCl, 1.0f);
|
|
||||||
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_LINE_WIDTH_length);
|
|
||||||
clInsertLineWidth(&commandBuffer->binCl, 1.0f);
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_CLIPPER_XY_SCALING_length);
|
|
||||||
clInsertClipperXYScaling(&commandBuffer->binCl, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_CLIPPER_Z_SCALE_AND_OFFSET_length);
|
|
||||||
clInsertClipperZScaleOffset(&commandBuffer->binCl, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_VIEWPORT_OFFSET_length);
|
|
||||||
clInsertViewPortOffset(&commandBuffer->binCl, 0, 0);
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_FLAT_SHADE_FLAGS_length);
|
|
||||||
clInsertFlatShadeFlags(&commandBuffer->binCl, 0);
|
|
||||||
|
|
||||||
//TODO I suppose this should be a submit itself?
|
|
||||||
*/
|
*/
|
||||||
|
VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
||||||
|
VkCommandBuffer commandBuffer,
|
||||||
|
VkImage image,
|
||||||
|
VkImageLayout imageLayout,
|
||||||
|
const VkClearColorValue* pColor,
|
||||||
|
uint32_t rangeCount,
|
||||||
|
const VkImageSubresourceRange* pRanges)
|
||||||
|
{
|
||||||
|
assert(commandBuffer);
|
||||||
|
assert(image);
|
||||||
|
assert(pColor);
|
||||||
|
|
||||||
|
//TODO this should only flag an image for clearing. This can only be called outside a renderpass
|
||||||
|
//actual clearing would only happen:
|
||||||
|
// -if image is rendered to (insert clear before first draw call)
|
||||||
|
// -if the image is bound for sampling (submit a CL with a clear)
|
||||||
|
// -if a command buffer is submitted without any rendering (insert clear)
|
||||||
|
// -etc.
|
||||||
|
//we shouldn't clear an image if noone uses it
|
||||||
|
|
||||||
|
//TODO ranges support
|
||||||
|
|
||||||
|
assert(imageLayout == VK_IMAGE_LAYOUT_GENERAL ||
|
||||||
|
imageLayout == VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR ||
|
||||||
|
imageLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
|
|
||||||
|
assert(commandBuffer->state == CMDBUF_STATE_RECORDING);
|
||||||
|
assert(_queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT || _queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_COMPUTE_BIT);
|
||||||
|
|
||||||
|
_image* i = image;
|
||||||
|
|
||||||
|
assert(i->usageBits & VK_IMAGE_USAGE_TRANSFER_DST_BIT);
|
||||||
|
|
||||||
|
//TODO externally sync cmdbuf, cmdpool
|
||||||
|
|
||||||
|
i->needToClear = 1;
|
||||||
|
i->clearColor[0] = i->clearColor[1] = packVec4IntoABGR8(pColor->float32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -32,6 +32,9 @@ typedef struct VkImage_T
|
|||||||
uint32_t format;
|
uint32_t format;
|
||||||
uint32_t imageSpace;
|
uint32_t imageSpace;
|
||||||
uint32_t tiling;
|
uint32_t tiling;
|
||||||
|
uint32_t needToClear;
|
||||||
|
uint32_t clearColor[2];
|
||||||
|
uint32_t layout;
|
||||||
uint32_t concurrentAccess; //TODO
|
uint32_t concurrentAccess; //TODO
|
||||||
uint32_t numQueueFamiliesWithAccess;
|
uint32_t numQueueFamiliesWithAccess;
|
||||||
uint32_t* queueFamiliesWithAccess;
|
uint32_t* queueFamiliesWithAccess;
|
||||||
|
Loading…
Reference in New Issue
Block a user