mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-01-30 22:52:14 +01:00
backup
This commit is contained in:
parent
78a7fa4875
commit
0fd991cd39
@ -316,8 +316,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)(
|
||||
//first entry is assumed to be a marker
|
||||
CLMarker* marker = getCPAptrFromOffset(cmdbuf->binCl.CPA, cmdbuf->binCl.offset);
|
||||
|
||||
assert(marker->memGuard == 0xDDDDDDDD);
|
||||
|
||||
//a command buffer may contain multiple render passes
|
||||
//and commands outside render passes such as clear commands
|
||||
//each of these corresponds to a control list submit
|
||||
@ -325,6 +323,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)(
|
||||
//submit each separate control list
|
||||
while(marker)
|
||||
{
|
||||
assert(marker->memGuard == 0xDDDDDDDD);
|
||||
|
||||
struct drm_vc4_submit_cl submitCl =
|
||||
{
|
||||
.color_read.hindex = ~0,
|
||||
@ -643,6 +643,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)(
|
||||
|
||||
assert(submitCl.bo_handle_count > 0);
|
||||
|
||||
fprintf(stderr, "submit bincl size: %u\n", submitCl.bin_cl_size);
|
||||
|
||||
//TODO
|
||||
while(lastSeqnoGuard);
|
||||
{
|
||||
@ -652,6 +654,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)(
|
||||
lastSeqnoGuard = 0;
|
||||
}
|
||||
|
||||
assert(marker->memGuard == 0xDDDDDDDD);
|
||||
|
||||
//advance in linked list
|
||||
marker = marker->nextMarkerOffset == -1 ? 0 : getCPAptrFromOffset(cmdbuf->binCl.CPA, marker->nextMarkerOffset);
|
||||
}
|
||||
|
@ -1079,6 +1079,8 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyBufferToImage)(
|
||||
|
||||
img->layout = dstImageLayout;
|
||||
|
||||
assert(((CLMarker*)getCPAptrFromOffset(cmdBuf->binCl.CPA, cmdBuf->binCl.offset))->memGuard == 0xDDDDDDDD);
|
||||
|
||||
PROFILEEND(RPIFUNC(vkCmdCopyBufferToImage));
|
||||
}
|
||||
|
||||
@ -1243,6 +1245,8 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdBlitImage)(
|
||||
RPIFUNC(vkDestroyFramebuffer)(device, offscreenFramebuffer, 0);
|
||||
}
|
||||
|
||||
assert(((CLMarker*)getCPAptrFromOffset(cmdBuf->binCl.CPA, cmdBuf->binCl.offset))->memGuard == 0xDDDDDDDD);
|
||||
|
||||
PROFILEEND(RPIFUNC(vkCmdBlitImage));
|
||||
}
|
||||
|
||||
@ -1281,24 +1285,22 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyImageToBuffer)(
|
||||
_image* img = srcImage;
|
||||
_buffer* buf = dstBuffer;
|
||||
|
||||
uint32_t srcPixelBpp = getFormatBpp(img->format);
|
||||
|
||||
for(uint32_t c = 0; c < regionCount; ++c)
|
||||
{
|
||||
//TODO support this
|
||||
assert(!pRegions[c].bufferRowLength);
|
||||
assert(!pRegions[c].bufferImageHeight);
|
||||
|
||||
uint32_t size = pRegions[c].imageExtent.width * pRegions[c].imageExtent.height;
|
||||
|
||||
uint32_t pixelBpp = getFormatBpp(img->format);
|
||||
|
||||
for(uint32_t d = 0, offsetX = 0, offsetY = 0; d < size; d += 2048)
|
||||
//copy image to buffer line by line
|
||||
for(uint32_t offsetY = 0; offsetY < pRegions[c].imageExtent.height; offsetY++)
|
||||
{
|
||||
uint32_t width = size - d;
|
||||
width = width < 2048 ? width : 2048;
|
||||
fprintf(stderr, "copying offsetY: %u\n", offsetY);
|
||||
|
||||
VkImageCreateInfo ici = {};
|
||||
ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
ici.extent.width = width;
|
||||
ici.extent.width = pRegions[c].imageExtent.width;
|
||||
ici.extent.height = 1;
|
||||
ici.arrayLayers = 1;
|
||||
ici.format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
@ -1309,14 +1311,13 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyImageToBuffer)(
|
||||
ici.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
VkImage dstDummyImage;
|
||||
vkCreateImage(device, &ici, 0, &dstDummyImage);
|
||||
RPIFUNC(vkCreateImage)(device, &ici, 0, &dstDummyImage);
|
||||
|
||||
//working with 32 bits per pixel
|
||||
vkBindImageMemory(device, dstDummyImage, buf->boundMem, buf->boundOffset + d * 4);
|
||||
RPIFUNC(vkBindImageMemory)(device, dstDummyImage, buf->boundMem, buf->boundOffset + (offsetY * pRegions[c].imageExtent.width * srcPixelBpp) >> 3);
|
||||
|
||||
VkImageBlit blit;
|
||||
blit.srcOffsets[0] = pRegions[c].imageOffset;
|
||||
blit.srcOffsets[0].x += offsetX;
|
||||
blit.srcOffsets[0].y += offsetY;
|
||||
blit.srcOffsets[1].x = pRegions[c].imageExtent.width;
|
||||
blit.srcOffsets[1].y = pRegions[c].imageExtent.height;
|
||||
@ -1329,18 +1330,17 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyImageToBuffer)(
|
||||
blit.dstOffsets[0].x = 0;
|
||||
blit.dstOffsets[0].y = 0;
|
||||
blit.dstOffsets[0].z = 0;
|
||||
blit.dstOffsets[1].x = width;
|
||||
blit.dstOffsets[1].x = pRegions[c].imageExtent.width;
|
||||
blit.dstOffsets[1].y = 1;
|
||||
blit.dstOffsets[1].z = 1;
|
||||
RPIFUNC(vkCmdBlitImage)(commandBuffer, srcImage, srcImageLayout, dstDummyImage, ici.initialLayout, 1, &blit, VK_FILTER_NEAREST);
|
||||
|
||||
RPIFUNC(vkDestroyImage)(device, dstDummyImage, 0);
|
||||
|
||||
//TODO??
|
||||
//offsetY += (offsetX + 2048)
|
||||
}
|
||||
}
|
||||
|
||||
assert(((CLMarker*)getCPAptrFromOffset(cmdbuf->binCl.CPA, cmdbuf->binCl.offset))->memGuard == 0xDDDDDDDD);
|
||||
|
||||
PROFILEEND(RPIFUNC(vkCmdCopyImageToBuffer));
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ VkResult RPIFUNC(vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceM
|
||||
|
||||
assert(!buf->boundMem);
|
||||
assert(memoryOffset < mem->size);
|
||||
assert(memoryOffset % buf->alignment == 0);
|
||||
//assert(memoryOffset % buf->alignment == 0);
|
||||
assert(buf->alignedSize <= mem->size - memoryOffset);
|
||||
|
||||
buf->boundMem = mem;
|
||||
@ -450,7 +450,7 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkBindImageMemory)(
|
||||
|
||||
assert(!i->boundMem);
|
||||
assert(memoryOffset < m->size);
|
||||
assert(memoryOffset % i->alignment == 0);
|
||||
//assert(memoryOffset % i->alignment == 0);
|
||||
assert(i->size <= m->size - memoryOffset);
|
||||
|
||||
i->boundMem = m;
|
||||
|
@ -193,11 +193,11 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdPipelineBarrier)(
|
||||
{
|
||||
_image* i = pImageMemoryBarriers[c].image;
|
||||
|
||||
if(srcStageMask & VK_PIPELINE_STAGE_TRANSFER_BIT &&
|
||||
pImageMemoryBarriers[c].srcAccessMask & VK_ACCESS_TRANSFER_WRITE_BIT)
|
||||
{
|
||||
assert(i->layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
// if(srcStageMask & VK_PIPELINE_STAGE_TRANSFER_BIT &&
|
||||
// pImageMemoryBarriers[c].srcAccessMask & VK_ACCESS_TRANSFER_WRITE_BIT)
|
||||
// {
|
||||
// assert(i->layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
// }
|
||||
|
||||
//transition to new layout
|
||||
i->layout = pImageMemoryBarriers[c].newLayout;
|
||||
|
@ -1303,7 +1303,7 @@ void CreateTexture()
|
||||
VkBuffer stagingBuffer;
|
||||
VkDeviceMemory stagingMemory;
|
||||
|
||||
{ //create storage texel buffer for generic mem address TMU ops test
|
||||
{ //create staging buffer for texture upload
|
||||
VkBufferCreateInfo bufferCreateInfo = {};
|
||||
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||
bufferCreateInfo.size = width * height * 4;
|
||||
@ -1331,7 +1331,60 @@ void CreateTexture()
|
||||
vkBindBufferMemory(device, stagingBuffer, stagingMemory, 0);
|
||||
}
|
||||
|
||||
{ //create texture that we'll write to
|
||||
VkDeviceMemory tmpImageMemory, tmpBufferMemory;
|
||||
VkImage tmpImage;
|
||||
VkBuffer tmpBuffer;
|
||||
|
||||
{ //create tmp buffer for image to buffer copy
|
||||
VkBufferCreateInfo bufferCreateInfo = {};
|
||||
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||
bufferCreateInfo.size = width * height * 4;
|
||||
bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
vkCreateBuffer(device, &bufferCreateInfo, 0, &tmpBuffer);
|
||||
|
||||
VkMemoryRequirements mr;
|
||||
vkGetBufferMemoryRequirements(device, tmpBuffer, &mr);
|
||||
|
||||
VkMemoryAllocateInfo mai = {};
|
||||
mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
mai.allocationSize = mr.size;
|
||||
mai.memoryTypeIndex = getMemoryTypeIndex(pdmp, mr.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||
|
||||
vkAllocateMemory(device, &mai, 0, &tmpBufferMemory);
|
||||
|
||||
vkBindBufferMemory(device, tmpBuffer, tmpBufferMemory, 0);
|
||||
}
|
||||
|
||||
{ //create tmp image for image to buffer copy
|
||||
VkImageCreateInfo imageCreateInfo = {};
|
||||
imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
|
||||
imageCreateInfo.format = format;
|
||||
imageCreateInfo.mipLevels = mipLevels;
|
||||
imageCreateInfo.arrayLayers = 1;
|
||||
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageCreateInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imageCreateInfo.extent = { width, height, 1 };
|
||||
vkCreateImage(device, &imageCreateInfo, 0, &tmpImage);
|
||||
|
||||
VkMemoryRequirements mr;
|
||||
vkGetImageMemoryRequirements(device, tmpImage, &mr);
|
||||
|
||||
VkMemoryAllocateInfo mai = {};
|
||||
mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
mai.allocationSize = mr.size;
|
||||
mai.memoryTypeIndex = getMemoryTypeIndex(pdmp, mr.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
vkAllocateMemory(device, &mai, 0, &tmpImageMemory);
|
||||
|
||||
vkBindImageMemory(device, tmpImage, tmpImageMemory, 0);
|
||||
}
|
||||
|
||||
{ //create final texture
|
||||
VkImageCreateInfo imageCreateInfo = {};
|
||||
imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
|
||||
@ -1382,7 +1435,7 @@ void CreateTexture()
|
||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
imageMemoryBarrier.image = textureImage;
|
||||
imageMemoryBarrier.image = tmpImage;
|
||||
imageMemoryBarrier.subresourceRange = subresourceRange;
|
||||
|
||||
VkCommandBufferBeginInfo beginInfo = {};
|
||||
@ -1406,9 +1459,44 @@ void CreateTexture()
|
||||
bufferCopyRegion.imageExtent.depth = 1;
|
||||
bufferCopyRegion.bufferOffset = 0;
|
||||
|
||||
//copy image from staging buffer to tmp image
|
||||
vkCmdCopyBufferToImage(
|
||||
copyCommandBuffer,
|
||||
stagingBuffer,
|
||||
tmpImage,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
&bufferCopyRegion);
|
||||
|
||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
|
||||
vkCmdPipelineBarrier(copyCommandBuffer,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
|
||||
//test image to buffer copies, copy tmpimage to tmpbuf
|
||||
vkCmdCopyImageToBuffer(copyCommandBuffer, tmpImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
tmpBuffer, 1, &bufferCopyRegion);
|
||||
|
||||
|
||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
|
||||
vkCmdPipelineBarrier(copyCommandBuffer,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
|
||||
//copy from tmpbuf to final texture
|
||||
vkCmdCopyBufferToImage(
|
||||
copyCommandBuffer,
|
||||
tmpBuffer,
|
||||
textureImage,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user