diff --git a/chip/ps4_gpu_regs.pas b/chip/ps4_gpu_regs.pas index bfc78ef..d4d990e 100644 --- a/chip/ps4_gpu_regs.pas +++ b/chip/ps4_gpu_regs.pas @@ -904,6 +904,101 @@ begin end; end; +function GetRenderTargetFormat(FORMAT,NUMBER_TYPE:Byte):TVkFormat; +begin + Result:=VK_FORMAT_UNDEFINED; + + Case FORMAT of + COLOR_8: + Case NUMBER_TYPE of + NUMBER_UNORM:Result:=VK_FORMAT_R8_UNORM; + NUMBER_SNORM:Result:=VK_FORMAT_R8_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R8_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R8_SINT; + else; + end; + COLOR_8_8: + Case NUMBER_TYPE of + NUMBER_UNORM:Result:=VK_FORMAT_R8G8_UNORM; + NUMBER_SNORM:Result:=VK_FORMAT_R8G8_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R8G8_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R8G8_SINT; + else; + end; + COLOR_8_8_8_8: + Case NUMBER_TYPE of + NUMBER_UNORM:Result:=VK_FORMAT_R8G8B8A8_UNORM; + NUMBER_SRGB :Result:=VK_FORMAT_R8G8B8A8_SRGB; + NUMBER_SNORM:Result:=VK_FORMAT_R8G8B8A8_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R8G8B8A8_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R8G8B8A8_SINT; + else; + end; + + COLOR_16: + Case NUMBER_TYPE of + NUMBER_UNORM :Result:=VK_FORMAT_R16_UNORM; + NUMBER_SNORM :Result:=VK_FORMAT_R16_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R16_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R16_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R16_SFLOAT; + else; + end; + COLOR_16_16: + Case NUMBER_TYPE of + NUMBER_UNORM :Result:=VK_FORMAT_R16G16_UNORM; + NUMBER_SNORM :Result:=VK_FORMAT_R16G16_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R16G16_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R16G16_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R16G16_SFLOAT; + else; + end; + COLOR_16_16_16_16: + Case NUMBER_TYPE of + NUMBER_UNORM :Result:=VK_FORMAT_R16G16B16A16_UNORM; + NUMBER_SNORM :Result:=VK_FORMAT_R16G16B16A16_SNORM; + NUMBER_UINT :Result:=VK_FORMAT_R16G16B16A16_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R16G16B16A16_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R16G16B16A16_SFLOAT; + else; + end; + + COLOR_32: + Case NUMBER_TYPE of + NUMBER_UINT :Result:=VK_FORMAT_R32_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R32_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R32_SFLOAT; + else; + end; + COLOR_32_32: + Case NUMBER_TYPE of + NUMBER_UINT :Result:=VK_FORMAT_R32G32_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R32G32_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R32G32_SFLOAT; + else; + end; + COLOR_32_32_32_32: + Case NUMBER_TYPE of + NUMBER_UINT :Result:=VK_FORMAT_R32G32B32A32_UINT; + NUMBER_SINT :Result:=VK_FORMAT_R32G32B32A32_SINT; + NUMBER_FLOAT :Result:=VK_FORMAT_R32G32B32A32_SFLOAT; + else; + end; + + else; + end; + + if (Result=VK_FORMAT_UNDEFINED) then + begin + Assert(false,'Unknow Rebder target format:'+IntTostr(FORMAT)+':'+IntTostr(NUMBER_TYPE)); + end; + +end; + +// +//FORMAT :=RENDER_TARGET[i].INFO.FORMAT; +//NUMBER_TYPE:=RENDER_TARGET[i].INFO.NUMBER_TYPE; + Function TGPU_REGS.GET_RT_INFO(i:Byte):TRT_INFO; //0..7 var COMP_MAP:TCOMP_MAP; @@ -932,35 +1027,7 @@ begin FORMAT :=RENDER_TARGET[i].INFO.FORMAT; NUMBER_TYPE:=RENDER_TARGET[i].INFO.NUMBER_TYPE; - Case FORMAT of - COLOR_8: - Case NUMBER_TYPE of - NUMBER_UNORM:Result.FImageInfo.cformat:=VK_FORMAT_R8_UNORM; - NUMBER_SRGB :Result.FImageInfo.cformat:=VK_FORMAT_R8_SRGB; - else - Assert(false,'TODO'); - end; - COLOR_8_8_8_8: - Case NUMBER_TYPE of - NUMBER_UNORM:Result.FImageInfo.cformat:=VK_FORMAT_R8G8B8A8_UNORM; - NUMBER_SRGB :Result.FImageInfo.cformat:=VK_FORMAT_R8G8B8A8_SRGB; - else - Assert(false,'TODO'); - end; - COLOR_16_16: - Case NUMBER_TYPE of - NUMBER_UNORM :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_UNORM; - NUMBER_SRGB :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_UNORM; - NUMBER_SNORM :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_SNORM; - NUMBER_USCALED:Result.FImageInfo.cformat:=VK_FORMAT_R16G16_USCALED; - NUMBER_SSCALED:Result.FImageInfo.cformat:=VK_FORMAT_R16G16_SSCALED; - NUMBER_UINT :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_UINT; - NUMBER_SINT :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_SINT; - NUMBER_FLOAT :Result.FImageInfo.cformat:=VK_FORMAT_R16G16_SFLOAT; - end; - else - Assert(false,'TODO'); - end; + Result.FImageInfo.cformat:=GetRenderTargetFormat(FORMAT,NUMBER_TYPE); if (RENDER_TARGET[i].INFO.LINEAR_GENERAL<>0) then Result.FImageInfo.params.tiling_idx:=kTileModeDisplay_LinearGeneral @@ -1029,6 +1096,7 @@ begin Result.CLEAR_COLOR.uint32[3]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[3]) shl 3),$FF); end; + COLOR_16, COLOR_16_16, COLOR_16_16_16_16: begin @@ -1042,6 +1110,21 @@ begin Result.CLEAR_COLOR.uint32[3]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[3]) shl 4),$FFFF); end; + COLOR_32, + COLOR_32_32: + begin + COMP_MAP:=GetCompMap(RENDER_TARGET[i].INFO.COMP_SWAP,4); + + W:=RENDER_TARGET[i].CLEAR_WORD; + + Result.CLEAR_COLOR.uint32[0]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[0]) shl 5),$FFFFFFFF); + Result.CLEAR_COLOR.uint32[1]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[1]) shl 5),$FFFFFFFF); + Result.CLEAR_COLOR.uint32[2]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[2]) shl 5),$FFFFFFFF); + Result.CLEAR_COLOR.uint32[3]:=_conv_clr_to_float(NUMBER_TYPE,W shr (BsrDWord(COMP_MAP[3]) shl 5),$FFFFFFFF); + end; + + COLOR_32_32_32_32:; //128bit ignore + else Assert(false); end; @@ -1634,6 +1717,9 @@ begin IMG_NUM_FORMAT_FLOAT : case PT^.dfmt of + IMG_DATA_FORMAT_16 :Result:=VK_FORMAT_R16_SFLOAT; + IMG_DATA_FORMAT_16_16 :Result:=VK_FORMAT_R16G16_SFLOAT; + IMG_DATA_FORMAT_16_16_16_16:Result:=VK_FORMAT_R16G16B16A16_SFLOAT; IMG_DATA_FORMAT_32 :Result:=VK_FORMAT_R32_SFLOAT; IMG_DATA_FORMAT_32_32 :Result:=VK_FORMAT_R32G32_SFLOAT; IMG_DATA_FORMAT_32_32_32 :Result:=VK_FORMAT_R32G32B32_SFLOAT; diff --git a/vulkan/vImage.pas b/vulkan/vImage.pas index 0c48dc2..1e12023 100644 --- a/vulkan/vImage.pas +++ b/vulkan/vImage.pas @@ -178,16 +178,56 @@ begin Result:=0; Case cformat of //pixel size - VK_FORMAT_R8G8B8A8_SRGB :Result:=4; - VK_FORMAT_R8G8B8A8_UNORM :Result:=4; - VK_FORMAT_R8G8_UNORM :Result:=2; + VK_FORMAT_R8_UNORM :Result:=1; + VK_FORMAT_R8_SNORM :Result:=1; VK_FORMAT_R8_UINT :Result:=1; + VK_FORMAT_R8_SINT :Result:=1; VK_FORMAT_R8_SRGB :Result:=1; + + VK_FORMAT_R8G8_UNORM :Result:=2; + VK_FORMAT_R8G8_SNORM :Result:=2; + VK_FORMAT_R8G8_UINT :Result:=2; + VK_FORMAT_R8G8_SINT :Result:=2; + + VK_FORMAT_R8G8B8A8_UNORM :Result:=4; + VK_FORMAT_R8G8B8A8_SRGB :Result:=4; + VK_FORMAT_R8G8B8A8_SNORM :Result:=4; + VK_FORMAT_R8G8B8A8_UINT :Result:=4; + VK_FORMAT_R8G8B8A8_SINT :Result:=4; + + VK_FORMAT_R16_UNORM :Result:=2; + VK_FORMAT_R16_SNORM :Result:=2; + VK_FORMAT_R16_UINT :Result:=2; + VK_FORMAT_R16_SINT :Result:=2; + VK_FORMAT_R16_SFLOAT :Result:=2; + + VK_FORMAT_R16G16_UNORM :Result:=4; + VK_FORMAT_R16G16_SNORM :Result:=4; + VK_FORMAT_R16G16_UINT :Result:=4; + VK_FORMAT_R16G16_SINT :Result:=4; + VK_FORMAT_R16G16_SFLOAT :Result:=4; + + VK_FORMAT_R16G16B16A16_UNORM :Result:=8; + VK_FORMAT_R16G16B16A16_SNORM :Result:=8; + VK_FORMAT_R16G16B16A16_UINT :Result:=8; + VK_FORMAT_R16G16B16A16_SINT :Result:=8; + VK_FORMAT_R16G16B16A16_SFLOAT :Result:=8; + + VK_FORMAT_R32_UINT :Result:=4; + VK_FORMAT_R32_SINT :Result:=4; + VK_FORMAT_R32_SFLOAT :Result:=4; + + VK_FORMAT_R32G32_UINT :Result:=8; + VK_FORMAT_R32G32_SINT :Result:=8; + VK_FORMAT_R32G32_SFLOAT :Result:=8; + + VK_FORMAT_R32G32B32A32_UINT :Result:=16; + VK_FORMAT_R32G32B32A32_SINT :Result:=16; + VK_FORMAT_R32G32B32A32_SFLOAT :Result:=16; + VK_FORMAT_R5G6B5_UNORM_PACK16 :Result:=2; VK_FORMAT_R4G4B4A4_UNORM_PACK16:Result:=2; - VK_FORMAT_R16G16_SFLOAT :Result:=4; - VK_FORMAT_R32_SFLOAT :Result:=4; //stencil VK_FORMAT_S8_UINT :Result:=1; diff --git a/vulkan/vImageTiling.pas b/vulkan/vImageTiling.pas index ba04f76..a79c705 100644 --- a/vulkan/vImageTiling.pas +++ b/vulkan/vImageTiling.pas @@ -360,6 +360,11 @@ begin tiler.m_paddedDepth :=tiler.m_linearDepth ; end else Case m_bitsPerElement of + 64:begin + tiler.m_paddedWidth :=(tiler.m_linearWidth +3) and (not 3); + tiler.m_paddedHeight:=(tiler.m_linearHeight+7) and (not 7); + tiler.m_paddedDepth :=tiler.m_linearDepth; + end; 32:begin tiler.m_paddedWidth :=(tiler.m_linearWidth +7) and (not 7); tiler.m_paddedHeight:=(tiler.m_linearHeight+7) and (not 7);