mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-02-20 17:54:17 +01:00
added ETC test, but can't make it work
need kernel support for 64bpp output so that I can emulate the copy to optimal format
This commit is contained in:
parent
aeca99ff62
commit
0eab6f0a0e
@ -926,6 +926,8 @@ uint32_t getRenderTargetFormatVC4(VkFormat format)
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
//only here so we can do emulated buffer copies to depth textures
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
//only here so we can copy ETC1 textures to optimal format
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
return VC4_RENDER_CONFIG_FORMAT_RGBA8888;
|
||||
case VK_FORMAT_B5G6R5_UNORM_PACK16:
|
||||
|
@ -153,7 +153,14 @@ void createSampler(VkDevice device, VkSampler* textureSampler)
|
||||
|
||||
void createRendertarget(VkDevice device, uint32_t width, uint32_t height, VkImage textureImage, VkImageView* textureView, VkRenderPass* offscreenRenderPass, VkFramebuffer* offscreenFramebuffer)
|
||||
{
|
||||
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
_image* img = textureImage;
|
||||
VkFormat format = img->format;
|
||||
|
||||
//we can't render to an ETC1 texture, so we'll just stick with RGBA8 for now
|
||||
if(img->format == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK)
|
||||
{
|
||||
format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
|
||||
VkImageViewCreateInfo view = {};
|
||||
view.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
@ -459,7 +466,8 @@ void createShaderModule(VkDevice device, VkShaderModule* blitShaderModule)
|
||||
"sig_none ; r1 = itof.always(b, b, x_pix, y_pix) ; nop = nop(r0, r0) ;" //FragCoord Y
|
||||
"sig_none ; r0 = itof.always(a, a, x_pix, y_pix) ; r1 = fmul.always(r1, r2) ;" //FragCoord X, r1 = Y * width
|
||||
"sig_none ; r0 = fadd.always(r0, r1) ; r0 = nop(r0, r0) ;" //r0 = Y * width + X
|
||||
"sig_none ; r0 = nop(r0, r0, nop, uni) ; r0 = fmul.always(r0, b) ;" //r0 = (Y * width + X) * pixelBytes
|
||||
"sig_none ; r0 = nop(r0, r0, nop, uni) ; r0 = fmul.always(r0, b) ;" //r0 = (Y * width + X) * pixelBpp
|
||||
"sig_small_imm ; nop = nop(r0, r0, nop, 0x3e000000) ; r0 = fmul.always(r0, b) ;" //r0 = ((Y * width + X) * pixelBpp) / 8
|
||||
"sig_none ; r0 = ftoi.always(r0, r0) ; nop = nop(r0, r0) ;" //convert to integer
|
||||
///write general mem access address
|
||||
///first argument must be clamped to [0...bufsize-4]
|
||||
@ -626,13 +634,15 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyBufferToImage(
|
||||
|
||||
uint32_t width = pRegions[c].imageExtent.width, height = pRegions[c].imageExtent.height;
|
||||
|
||||
uint32_t pixelBpp = getFormatBpp(img->format);
|
||||
|
||||
VkBufferView texelBufferView;
|
||||
VkBufferViewCreateInfo bvci = {};
|
||||
bvci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
|
||||
bvci.buffer = buf;
|
||||
bvci.format = img->format;
|
||||
bvci.offset = pRegions[c].bufferOffset;
|
||||
bvci.range = width * height * getFormatBpp(img->format) / 8;
|
||||
bvci.range = (width * height * pixelBpp) >> 3;
|
||||
rpi_vkCreateBufferView(device, &bvci, 0, &texelBufferView);
|
||||
|
||||
|
||||
@ -696,13 +706,12 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyBufferToImage(
|
||||
|
||||
rpi_vkCmdPushConstants(commandBuffer, blitPipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vertConstants), &vertConstants);
|
||||
|
||||
uint32_t pixelBytes = getFormatBpp(img->format) / 8;
|
||||
float w = width;
|
||||
float pbfloat = pixelBytes;
|
||||
uint32_t size = width * height * pixelBytes - pixelBytes;
|
||||
float bppfloat = pixelBpp;
|
||||
uint32_t size = ((width * height * pixelBpp) >> 3) - ((pixelBpp > 32 ? pixelBpp : 32) >> 3);
|
||||
uint32_t fragConstants[4];
|
||||
fragConstants[0] = *(uint32_t*)&w;
|
||||
fragConstants[1] = *(uint32_t*)&pbfloat;
|
||||
fragConstants[1] = *(uint32_t*)&bppfloat;
|
||||
fragConstants[2] = size;
|
||||
fragConstants[3] = 0;
|
||||
|
||||
|
@ -278,8 +278,7 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkGetImageMemoryRequirements(
|
||||
_image* i = image;
|
||||
|
||||
uint32_t bpp = getFormatBpp(i->format);
|
||||
uint32_t pixelSizeBytes = bpp / 8;
|
||||
uint32_t nonPaddedSize = i->width * i->height * pixelSizeBytes;
|
||||
uint32_t nonPaddedSize = (i->width * i->height * bpp) >> 3;
|
||||
i->paddedWidth = i->width;
|
||||
i->paddedHeight = i->height;
|
||||
|
||||
@ -292,8 +291,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkGetImageMemoryRequirements(
|
||||
}
|
||||
|
||||
//TODO does this need to be aligned?
|
||||
i->size = getBOAlignedSize(i->paddedWidth * i->paddedHeight * pixelSizeBytes, ARM_PAGE_SIZE);
|
||||
i->stride = i->paddedWidth * pixelSizeBytes;
|
||||
i->size = getBOAlignedSize((i->paddedWidth * i->paddedHeight * bpp) >> 3, ARM_PAGE_SIZE);
|
||||
i->stride = (i->paddedWidth * bpp) >> 3;
|
||||
|
||||
pMemoryRequirements->alignment = ARM_PAGE_SIZE;
|
||||
pMemoryRequirements->memoryTypeBits = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; //TODO
|
||||
|
@ -1313,15 +1313,12 @@ uint32_t getMemoryTypeIndex(VkPhysicalDeviceMemoryProperties deviceMemoryPropert
|
||||
|
||||
void CreateTexture()
|
||||
{
|
||||
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
VkFormat format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
||||
|
||||
uint32_t width = swapChainExtent.width, height = swapChainExtent.height;
|
||||
uint32_t width = 128, height = 128;
|
||||
uint32_t mipLevels = 1;
|
||||
|
||||
//char* texData = readPPM("image.ppm");
|
||||
//char* texData = readPPM("triangle.ppm");
|
||||
char* texData = readPKM("elina.pkm");
|
||||
exit(0);
|
||||
|
||||
VkBuffer stagingBuffer;
|
||||
VkDeviceMemory stagingMemory;
|
||||
@ -1329,7 +1326,7 @@ void CreateTexture()
|
||||
{ //create storage texel buffer for generic mem address TMU ops test
|
||||
VkBufferCreateInfo bufferCreateInfo = {};
|
||||
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||
bufferCreateInfo.size = width * height * 4;
|
||||
bufferCreateInfo.size = (width * height * 4) >> 3;
|
||||
bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
vkCreateBuffer(device, &bufferCreateInfo, 0, &stagingBuffer);
|
||||
@ -1346,7 +1343,7 @@ void CreateTexture()
|
||||
|
||||
void* data;
|
||||
vkMapMemory(device, stagingMemory, 0, mr.size, 0, &data);
|
||||
memcpy(data, texData, width * height * 4);
|
||||
memcpy(data, texData, bufferCreateInfo.size);
|
||||
vkUnmapMemory(device, stagingMemory);
|
||||
|
||||
free(texData);
|
||||
|
@ -1236,8 +1236,8 @@ void CreateTexture()
|
||||
uint32_t width = swapChainExtent.width, height = swapChainExtent.height;
|
||||
uint32_t mipLevels = 1;
|
||||
|
||||
//char* texData = readPPM("image.ppm");
|
||||
char* texData = readPPM("triangle.ppm");
|
||||
char* texData = readPPM("image.ppm");
|
||||
//char* texData = readPPM("triangle.ppm");
|
||||
|
||||
VkBuffer stagingBuffer;
|
||||
VkDeviceMemory stagingMemory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user