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
277
driver/driver.c
277
driver/driver.c
@ -1376,7 +1376,159 @@ VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
|
||||
{
|
||||
assert(commandBuffer);
|
||||
|
||||
//TODO
|
||||
//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
|
||||
}
|
||||
|
||||
for(int c = 0; c < bufferMemoryBarrierCount; ++c)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
for(int c = 0; c < imageMemoryBarrierCount; ++c)
|
||||
{
|
||||
_image* i = pImageMemoryBarriers[c].image;
|
||||
|
||||
assert(i->layout == pImageMemoryBarriers[c].oldLayout || i->layout == VK_IMAGE_LAYOUT_UNDEFINED);
|
||||
|
||||
if(srcStageMask & VK_PIPELINE_STAGE_TRANSFER_BIT &&
|
||||
pImageMemoryBarriers[c].srcAccessMask & VK_ACCESS_TRANSFER_WRITE_BIT &&
|
||||
i->needToClear)
|
||||
{
|
||||
//insert CRs to clear the image
|
||||
|
||||
assert(i->layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
|
||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_TILE_BINNING_MODE_CONFIGURATION_length);
|
||||
clInsertTileBinningModeConfiguration(&commandBuffer->binCl,
|
||||
0, 0, 0, 0,
|
||||
getFormatBpp(i->format) == 64, //64 bit color mode
|
||||
i->samples > 1, //msaa
|
||||
i->width, i->height, 0, 0, 0);
|
||||
|
||||
//START_TILE_BINNING resets the statechange counters in the hardware,
|
||||
//which are what is used when a primitive is binned to a tile to
|
||||
//figure out what new state packets need to be written to that tile's
|
||||
//command list.
|
||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_START_TILE_BINNING_length);
|
||||
clInsertStartTileBinning(&commandBuffer->binCl);
|
||||
|
||||
//Reset the current compressed primitives format. This gets modified
|
||||
//by VC4_PACKET_GL_INDEXED_PRIMITIVE and
|
||||
//VC4_PACKET_GL_ARRAY_PRIMITIVE, so it needs to be reset at the start
|
||||
//of every tile.
|
||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_PRIMITIVE_LIST_FORMAT_length);
|
||||
clInsertPrimitiveListFormat(&commandBuffer->binCl,
|
||||
1, //16 bit
|
||||
2); //tris
|
||||
|
||||
clFit(commandBuffer, &commandBuffer->handlesCl, 4);
|
||||
uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, i->handle);
|
||||
commandBuffer->submitCl.color_write.hindex = idx;
|
||||
commandBuffer->submitCl.color_write.offset = 0;
|
||||
commandBuffer->submitCl.color_write.flags = 0;
|
||||
//TODO format
|
||||
commandBuffer->submitCl.color_write.bits =
|
||||
VC4_SET_FIELD(VC4_RENDER_CONFIG_FORMAT_RGBA8888, VC4_RENDER_CONFIG_FORMAT) |
|
||||
VC4_SET_FIELD(i->tiling, VC4_RENDER_CONFIG_MEMORY_FORMAT);
|
||||
|
||||
commandBuffer->submitCl.clear_color[0] = i->clearColor[0];
|
||||
commandBuffer->submitCl.clear_color[1] = i->clearColor[1];
|
||||
|
||||
//TODO ranges
|
||||
commandBuffer->submitCl.min_x_tile = 0;
|
||||
commandBuffer->submitCl.min_y_tile = 0;
|
||||
|
||||
uint32_t tileSizeW = 64;
|
||||
uint32_t tileSizeH = 64;
|
||||
|
||||
if(i->samples > 1)
|
||||
{
|
||||
tileSizeW >>= 1;
|
||||
tileSizeH >>= 1;
|
||||
}
|
||||
|
||||
if(getFormatBpp(i->format) == 64)
|
||||
{
|
||||
tileSizeH >>= 1;
|
||||
}
|
||||
|
||||
uint32_t widthInTiles = divRoundUp(i->width, tileSizeW);
|
||||
uint32_t heightInTiles = divRoundUp(i->height, tileSizeH);
|
||||
|
||||
commandBuffer->submitCl.max_x_tile = widthInTiles - 1;
|
||||
commandBuffer->submitCl.max_y_tile = heightInTiles - 1;
|
||||
commandBuffer->submitCl.width = i->width;
|
||||
commandBuffer->submitCl.height = i->height;
|
||||
commandBuffer->submitCl.flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
||||
commandBuffer->submitCl.clear_z = 0; //TODO
|
||||
commandBuffer->submitCl.clear_s = 0;
|
||||
}
|
||||
|
||||
//transition to new layout
|
||||
i->layout = pImageMemoryBarriers[c].newLayout;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1400,7 +1552,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
||||
//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 the command buffer is closed without any rendering (insert clear)
|
||||
// -if a command buffer is submitted without any rendering (insert clear)
|
||||
// -etc.
|
||||
//we shouldn't clear an image if noone uses it
|
||||
|
||||
@ -1413,129 +1565,14 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
||||
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);
|
||||
|
||||
//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);
|
||||
clInsertTileBinningModeConfiguration(&commandBuffer->binCl,
|
||||
0, 0, 0, 0,
|
||||
getFormatBpp(i->format) == 64, //64 bit color mode
|
||||
i->samples > 1, //msaa
|
||||
i->width, i->height, 0, 0, 0);
|
||||
//TODO externally sync cmdbuf, cmdpool
|
||||
|
||||
//START_TILE_BINNING resets the statechange counters in the hardware,
|
||||
//which are what is used when a primitive is binned to a tile to
|
||||
//figure out what new state packets need to be written to that tile's
|
||||
//command list.
|
||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_START_TILE_BINNING_length);
|
||||
clInsertStartTileBinning(&commandBuffer->binCl);
|
||||
|
||||
//Reset the current compressed primitives format. This gets modified
|
||||
//by VC4_PACKET_GL_INDEXED_PRIMITIVE and
|
||||
//VC4_PACKET_GL_ARRAY_PRIMITIVE, so it needs to be reset at the start
|
||||
//of every tile.
|
||||
clFit(commandBuffer, &commandBuffer->binCl, V3D21_PRIMITIVE_LIST_FORMAT_length);
|
||||
clInsertPrimitiveListFormat(&commandBuffer->binCl,
|
||||
1, //16 bit
|
||||
2); //tris
|
||||
|
||||
clFit(commandBuffer, &commandBuffer->handlesCl, 4);
|
||||
uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, i->handle);
|
||||
commandBuffer->submitCl.color_write.hindex = idx;
|
||||
commandBuffer->submitCl.color_write.offset = 0;
|
||||
commandBuffer->submitCl.color_write.flags = 0;
|
||||
//TODO format
|
||||
commandBuffer->submitCl.color_write.bits =
|
||||
VC4_SET_FIELD(VC4_RENDER_CONFIG_FORMAT_RGBA8888, VC4_RENDER_CONFIG_FORMAT) |
|
||||
VC4_SET_FIELD(i->tiling, VC4_RENDER_CONFIG_MEMORY_FORMAT);
|
||||
|
||||
//TODO msaa?
|
||||
|
||||
commandBuffer->submitCl.clear_color[0] =
|
||||
commandBuffer->submitCl.clear_color[1] = packVec4IntoABGR8(pColor->float32);
|
||||
//TODO ranges
|
||||
commandBuffer->submitCl.min_x_tile = 0;
|
||||
commandBuffer->submitCl.min_y_tile = 0;
|
||||
|
||||
uint32_t tileSizeW = 64;
|
||||
uint32_t tileSizeH = 64;
|
||||
|
||||
if(i->samples > 1)
|
||||
{
|
||||
tileSizeW >>= 1;
|
||||
tileSizeH >>= 1;
|
||||
}
|
||||
|
||||
if(getFormatBpp(i->format) == 64)
|
||||
{
|
||||
tileSizeH >>= 1;
|
||||
}
|
||||
|
||||
uint32_t widthInTiles = divRoundUp(i->width, tileSizeW);
|
||||
uint32_t heightInTiles = divRoundUp(i->height, tileSizeH);
|
||||
|
||||
commandBuffer->submitCl.max_x_tile = widthInTiles - 1;
|
||||
commandBuffer->submitCl.max_y_tile = heightInTiles - 1;
|
||||
commandBuffer->submitCl.width = i->width;
|
||||
commandBuffer->submitCl.height = i->height;
|
||||
commandBuffer->submitCl.flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
||||
commandBuffer->submitCl.clear_z = 0; //TODO
|
||||
commandBuffer->submitCl.clear_s = 0;
|
||||
|
||||
//TODO primitive list format must be followed by shader state
|
||||
//clFit(commandBuffer, &commandBuffer->binCl, V3D21_GL_SHADER_STATE_length);
|
||||
//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?
|
||||
|
||||
/*
|
||||
//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?
|
||||
*/
|
||||
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 imageSpace;
|
||||
uint32_t tiling;
|
||||
uint32_t needToClear;
|
||||
uint32_t clearColor[2];
|
||||
uint32_t layout;
|
||||
uint32_t concurrentAccess; //TODO
|
||||
uint32_t numQueueFamiliesWithAccess;
|
||||
uint32_t* queueFamiliesWithAccess;
|
||||
|
Loading…
Reference in New Issue
Block a user