mirror of
https://github.com/Tinob/Ishiiruka.git
synced 2024-06-16 03:17:27 -04:00
Add support for hi precision buffer formats for the pp shaders. Also Add SuperDepth3d pp shader
This commit is contained in:
parent
5fffadb29c
commit
0965964893
357
Data/Sys/Shaders/Postprocessing/SuperDepth3D.glsl
Normal file
357
Data/Sys/Shaders/Postprocessing/SuperDepth3D.glsl
Normal file
|
@ -0,0 +1,357 @@
|
|||
////----------------//
|
||||
///**SuperDepth3D**///
|
||||
//----------------////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//* Depth Map Based 3D post-process shader v1.9.4 *//
|
||||
//* For Ishiiruka ported by Tino *//
|
||||
//* -------------------------- *//
|
||||
//* This work is licensed under a Creative Commons Attribution 3.0 Unported License. *//
|
||||
//* So you are free to share, modify and adapt it for your needs, and even use it for commercial use. *//
|
||||
//* I would also love to hear about a project you are using it with. *//
|
||||
//* https://creativecommons.org/licenses/by/3.0/us/ *//
|
||||
//* *//
|
||||
//* Have fun, *//
|
||||
//* Jose Negrete AKA BlueSkyDefender *//
|
||||
//* *//
|
||||
//* http://reshade.me/forum/shader-presentation/2128-sidebyside-3d-depth-map-based-stereoscopic-shader *//
|
||||
//* --------------------------------- *//
|
||||
//* *//
|
||||
//* Original work was based on Shader Based on CryTech 3 Dev work http://www.slideshare.net/TiagoAlexSousa/secrets-of-cryengine-3-graphics-technology *//
|
||||
//* *//
|
||||
//* *//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
|
||||
[configuration]
|
||||
[OptionRangeInteger]
|
||||
GUIName = Depth
|
||||
OptionName = A_Depth
|
||||
MinValue = 0
|
||||
MaxValue = 50
|
||||
StepAmount = 1
|
||||
DefaultValue = 15
|
||||
GUIDescription = Determines the amount of Image Warping and Separation between both eyes. You can Override this setting.
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Perspective
|
||||
OptionName = B_Perspective
|
||||
MinValue = -100
|
||||
MaxValue = 100
|
||||
StepAmount = 0.1
|
||||
DefaultValue = 0
|
||||
GUIDescription = Determines the perspective point. Default is 0.
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Depth Limit
|
||||
OptionName = C_Depth_Limit
|
||||
MinValue = 0.75
|
||||
MaxValue = 1.0
|
||||
StepAmount = 0.001
|
||||
DefaultValue = 1.0
|
||||
GUIDescription = Limit how far Depth Image Warping is done. Default is One.
|
||||
|
||||
[OptionRangeInteger]
|
||||
GUIName = Disocclusion Type
|
||||
OptionName = D_Disocclusion_Type
|
||||
MinValue = 0
|
||||
MaxValue = 2
|
||||
StepAmount = 1
|
||||
DefaultValue = 1
|
||||
GUIDescription = Pick the type of disocclusion you want.
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Disocclusion Power
|
||||
OptionName = E_Disocclusion_Power
|
||||
MinValue = 0
|
||||
MaxValue = 0.5
|
||||
StepAmount = 0.001
|
||||
DefaultValue = 0.025
|
||||
GUIDescription = Determines the disocclusion effect on the Depth Map. Default is 0.025.
|
||||
|
||||
[OptionBool]
|
||||
GUIName = Depth Map View
|
||||
OptionName = F_Depth_Map_View
|
||||
DefaultValue = false
|
||||
GUIDescription = Display the Depth Map. Use This to Work on your Own Depth Map for your game.
|
||||
|
||||
[OptionBool]
|
||||
GUIName = Depth Map Enhancement
|
||||
OptionName = G_Depth_Map_Enhancement
|
||||
DefaultValue = false
|
||||
GUIDescription = Enable Or Dissable Depth Map Enhancement. Default is Off.
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Adjust
|
||||
OptionName = H_Adjust
|
||||
MinValue = 0
|
||||
MaxValue = 1.5
|
||||
StepAmount = 0.001
|
||||
DefaultValue = 1.0
|
||||
GUIDescription = Adjust DepthMap Enhancement, Dehancement occurs past one. Default is 1.0.
|
||||
|
||||
[OptionRangeInteger]
|
||||
GUIName = Edge Selection
|
||||
OptionName = K_Custom_Sidebars
|
||||
MinValue = 0
|
||||
MaxValue = 2
|
||||
StepAmount = 1
|
||||
DefaultValue = 1
|
||||
GUIDescription = Select how you like the Edge of the screen to look like. Mirrored Edges, Black Edges, Stretched Edges.
|
||||
|
||||
[OptionRangeInteger]
|
||||
GUIName = 3D Display Mode
|
||||
OptionName = L_Stereoscopic_Mode
|
||||
MinValue = 0
|
||||
MaxValue = 3
|
||||
StepAmount = 1
|
||||
DefaultValue = 0
|
||||
GUIDescription = Side by Side/Top and Bottom/Line Interlaced/Checkerboard 3D display output.
|
||||
|
||||
[OptionRangeInteger]
|
||||
GUIName = Downscaling Support
|
||||
OptionName = M_Downscaling_Support
|
||||
MinValue = 0
|
||||
MaxValue = 2
|
||||
StepAmount = 1
|
||||
DefaultValue = 0
|
||||
GUIDescription = Dynamic Super Resolution & Virtual Super Resolution downscaling support for Line Interlaced & Checkerboard 3D displays.
|
||||
|
||||
[OptionBool]
|
||||
GUIName = Eye Swap
|
||||
OptionName = N_Eye_Swap
|
||||
DefaultValue = false
|
||||
GUIDescription = Left right image change.
|
||||
|
||||
[Pass]
|
||||
EntryPoint = DisocclusionMask
|
||||
OutputScale = 0.5
|
||||
OutputFormat = R32_FLOAT
|
||||
Input0=DepthBuffer
|
||||
Input0Filter=Nearest
|
||||
Input0Mode=Clamp
|
||||
[Pass]
|
||||
EntryPoint = PS_renderLR
|
||||
Input0=PreviousPass
|
||||
Input0Filter=Linear
|
||||
Input0Mode=Clamp
|
||||
Input1=DepthBuffer
|
||||
Input1Filter=Nearest
|
||||
Input1Mode=Clamp
|
||||
Input2=ColorBuffer
|
||||
Input2Filter=Linear
|
||||
Input2Mode=Mirror
|
||||
Input3=ColorBuffer
|
||||
Input3Filter=Linear
|
||||
Input3Mode=Border
|
||||
Input4=ColorBuffer
|
||||
Input4Filter=Linear
|
||||
Input4Mode=Clamp
|
||||
[/configuration]
|
||||
*/
|
||||
|
||||
void DisocclusionMask()
|
||||
{
|
||||
float color = 0;
|
||||
|
||||
if(GetOption(D_Disocclusion_Type) > 0 && GetOption(E_Disocclusion_Power) > 0)
|
||||
{
|
||||
const float weight[10] =
|
||||
{
|
||||
-0.08, -0.05, -0.03, -0.02, -0.01,
|
||||
0.01, 0.02, 0.03, 0.05, 0.08
|
||||
};
|
||||
float2 dir;
|
||||
float B;
|
||||
float Con = 10;
|
||||
float2 texcoord = GetCoordinates();
|
||||
if(GetOption(D_Disocclusion_Type) == 1)
|
||||
{
|
||||
dir = float2(0.5,0);
|
||||
B = GetOption(E_Disocclusion_Power)*1.5;
|
||||
}
|
||||
|
||||
if(GetOption(D_Disocclusion_Type) == 2)
|
||||
{
|
||||
dir = 0.5 - texcoord;
|
||||
B = GetOption(E_Disocclusion_Power)*2;
|
||||
}
|
||||
|
||||
dir = normalize( dir );
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
float D = SampleDepthLocation(texcoord + dir * weight[i] * B);
|
||||
if(GetOption(G_Depth_Map_Enhancement) > 0)
|
||||
{
|
||||
float A = GetOption(H_Adjust);
|
||||
float cDF = 1.025;
|
||||
float cDN = 0;
|
||||
D = lerp(pow(abs((exp(D * log(cDF + cDN)) - cDN) / cDF),1000),D,A);
|
||||
}
|
||||
D = D/Con;
|
||||
color += D;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float D = SampleDepth();
|
||||
if(GetOption(G_Depth_Map_Enhancement) > 0)
|
||||
{
|
||||
float A = GetOption(H_Adjust);
|
||||
float cDF = 1.025;
|
||||
float cDN = 0;
|
||||
D = lerp(pow(abs((exp(D * log(cDF + cDN)) - cDN) / cDF),1000),D,A);
|
||||
}
|
||||
color = D;
|
||||
}
|
||||
SetOutput(float4(color, color, color, 1.0));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////Left/Right Eye////////////////////////////////////////////////////////
|
||||
void PS_renderLR()
|
||||
{
|
||||
const float samples[3] = {0.50, 0.66, 1.0};
|
||||
float DepthL = GetOption(C_Depth_Limit), DepthR = GetOption(C_Depth_Limit);
|
||||
float2 uv = float2(0.0,0.0);
|
||||
float D;
|
||||
float P;
|
||||
float2 pix = GetInvResolution().xy;
|
||||
float4 color = float4(0.0,0.0,0.0,0.0);
|
||||
if(OptionEnabled(N_Eye_Swap))
|
||||
{
|
||||
P = -GetOption(B_Perspective) * pix.x;
|
||||
D = -GetOption(A_Depth) * pix.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
P = GetOption(B_Perspective) * pix.x;
|
||||
D = GetOption(A_Depth) * pix.x;
|
||||
}
|
||||
|
||||
float2 texcoord = GetCoordinates();
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
uv.x = samples[j] * D;
|
||||
|
||||
if(GetOption(L_Stereoscopic_Mode) == 0)
|
||||
{
|
||||
DepthL = min(DepthL,SamplePrevLocation(float2((texcoord.x*2 + P)+uv.x, texcoord.y)).r);
|
||||
DepthR = min(DepthR,SamplePrevLocation(float2((texcoord.x*2-1 - P)-uv.x, texcoord.y)).r);
|
||||
}
|
||||
else if(GetOption(L_Stereoscopic_Mode) == 1)
|
||||
{
|
||||
DepthL = min(DepthL,SamplePrevLocation(float2((texcoord.x + P)+uv.x, texcoord.y*2)).r);
|
||||
DepthR = min(DepthR,SamplePrevLocation(float2((texcoord.x - P)-uv.x, texcoord.y*2-1)).r);
|
||||
}
|
||||
else
|
||||
{
|
||||
DepthL = min(DepthL,SamplePrevLocation(float2((texcoord.x + P)+uv.x, texcoord.y)).r);
|
||||
DepthR = min(DepthR,SamplePrevLocation(float2((texcoord.x - P)-uv.x, texcoord.y)).r);
|
||||
}
|
||||
}
|
||||
|
||||
if(OptionEnabled(F_Depth_Map_View))
|
||||
{
|
||||
color = SamplePrev().rrrr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetOption(L_Stereoscopic_Mode) == 0)
|
||||
{
|
||||
if(GetOption(K_Custom_Sidebars) == 0)
|
||||
{
|
||||
color = SampleInputLocation(2, texcoord.x < 0.5 ? float2((texcoord.x*2 + P) + DepthL * D , texcoord.y) : float2((texcoord.x*2-1 - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else if(GetOption(K_Custom_Sidebars) == 1)
|
||||
{
|
||||
color = SampleInputLocation(3, texcoord.x < 0.5 ? float2((texcoord.x*2 + P) + DepthL * D , texcoord.y) : float2((texcoord.x*2-1 - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = SampleInputLocation(4, texcoord.x < 0.5 ? float2((texcoord.x*2 + P) + DepthL * D , texcoord.y) : float2((texcoord.x*2-1 - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
}
|
||||
else if(GetOption(L_Stereoscopic_Mode) == 1)
|
||||
{
|
||||
if(GetOption(K_Custom_Sidebars) == 0)
|
||||
{
|
||||
color = SampleInputLocation(2, texcoord.y < 0.5 ? float2((texcoord.x+ P) + DepthL * D , texcoord.y*2) : float2((texcoord.x - P) - DepthR * D , texcoord.y*2-1));
|
||||
}
|
||||
else if(GetOption(K_Custom_Sidebars) == 1)
|
||||
{
|
||||
color = SampleInputLocation(3, texcoord.y < 0.5 ? float2((texcoord.x+ P) + DepthL * D , texcoord.y*2) : float2((texcoord.x - P) - DepthR * D , texcoord.y*2-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = SampleInputLocation(4, texcoord.y < 0.5 ? float2((texcoord.x+ P) + DepthL * D , texcoord.y*2) : float2((texcoord.x - P) - DepthR * D , texcoord.y*2-1));
|
||||
}
|
||||
}
|
||||
else if(GetOption(L_Stereoscopic_Mode) == 2)
|
||||
{
|
||||
float gridL;
|
||||
|
||||
if(GetOption(M_Downscaling_Support) == 0)
|
||||
{
|
||||
gridL = frac(texcoord.y*(GetResolution().y/2));
|
||||
}
|
||||
else if(GetOption(M_Downscaling_Support) == 1)
|
||||
{
|
||||
gridL = frac(texcoord.y*(1080.0/2));
|
||||
}
|
||||
else
|
||||
{
|
||||
gridL = frac(texcoord.y*(1081.0/2));
|
||||
}
|
||||
|
||||
if(GetOption(K_Custom_Sidebars) == 0)
|
||||
{
|
||||
color = SampleInputLocation(2, gridL > 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else if(GetOption(K_Custom_Sidebars) == 1)
|
||||
{
|
||||
color = SampleInputLocation(3, gridL > 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = SampleInputLocation(4, gridL > 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float gridy;
|
||||
float gridx;
|
||||
|
||||
if(GetOption(M_Downscaling_Support) == 0)
|
||||
{
|
||||
gridy = floor(texcoord.y*(GetResolution().y));
|
||||
gridx = floor(texcoord.x*(GetResolution().x));
|
||||
}
|
||||
else if(GetOption(M_Downscaling_Support) == 1)
|
||||
{
|
||||
gridy = floor(texcoord.y*(1080.0));
|
||||
gridx = floor(texcoord.x*(1080.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
gridy = floor(texcoord.y*(1081.0));
|
||||
gridx = floor(texcoord.x*(1081.0));
|
||||
}
|
||||
|
||||
if(GetOption(K_Custom_Sidebars) == 0)
|
||||
{
|
||||
color = SampleInputLocation(2, (int(gridy+gridx) & 1) < 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else if(GetOption(K_Custom_Sidebars) == 1)
|
||||
{
|
||||
color = SampleInputLocation(3, (int(gridy+gridx) & 1) < 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = SampleInputLocation(4, (int(gridy+gridx) & 1) < 0.5 ? float2((texcoord.x + P) + DepthL * D , texcoord.y) : float2((texcoord.x - P) - DepthR * D , texcoord.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
SetOutput(color);
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ PC_TexFormat TextureCache::GetNativeTextureFormat(const s32 texformat, const Tlu
|
|||
|
||||
TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config)
|
||||
{
|
||||
static const DXGI_FORMAT PC_TexFormat_To_DXGIFORMAT[12]
|
||||
static const DXGI_FORMAT PC_TexFormat_To_DXGIFORMAT[]
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN,//PC_TEX_FMT_NONE
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,//PC_TEX_FMT_BGRA32
|
||||
|
@ -280,7 +280,9 @@ TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntry
|
|||
DXGI_FORMAT_BC1_UNORM,//PC_TEX_FMT_DXT1
|
||||
DXGI_FORMAT_BC2_UNORM,//PC_TEX_FMT_DXT3
|
||||
DXGI_FORMAT_BC3_UNORM,//PC_TEX_FMT_DXT5
|
||||
DXGI_FORMAT_R32_FLOAT,//PC_TEX_FMT_R32
|
||||
DXGI_FORMAT_R32_FLOAT,//PC_TEX_FMT_R_FLOAT
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT,//PC_TEX_FMT_RGBA16_FLOAT
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT,//PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
if (config.rendertarget)
|
||||
{
|
||||
|
|
|
@ -305,7 +305,7 @@ PC_TexFormat TextureCache::GetNativeTextureFormat(const s32 texformat, const Tlu
|
|||
|
||||
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config)
|
||||
{
|
||||
static const DXGI_FORMAT PC_TexFormat_To_DXGIFORMAT[12]
|
||||
static const DXGI_FORMAT PC_TexFormat_To_DXGIFORMAT[14]
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN,//PC_TEX_FMT_NONE
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM,//PC_TEX_FMT_BGRA32
|
||||
|
@ -318,7 +318,9 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConf
|
|||
DXGI_FORMAT_BC1_UNORM,//PC_TEX_FMT_DXT1
|
||||
DXGI_FORMAT_BC2_UNORM,//PC_TEX_FMT_DXT3
|
||||
DXGI_FORMAT_BC3_UNORM,//PC_TEX_FMT_DXT5
|
||||
DXGI_FORMAT_R32_FLOAT,//PC_TEX_FMT_R32
|
||||
DXGI_FORMAT_R32_FLOAT,//PC_TEX_FMT_R_FLOAT
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT,//PC_TEX_FMT_RGBA16_FLOAT
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT,//PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
if (config.rendertarget)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ extern s32 frameCount;
|
|||
namespace DX9
|
||||
{
|
||||
|
||||
static const D3DFORMAT PC_TexFormat_To_D3DFORMAT[12]
|
||||
static const D3DFORMAT PC_TexFormat_To_D3DFORMAT[14]
|
||||
{
|
||||
D3DFMT_UNKNOWN,//PC_TEX_FMT_NONE
|
||||
D3DFMT_A8R8G8B8,//PC_TEX_FMT_BGRA32
|
||||
|
@ -51,10 +51,12 @@ static const D3DFORMAT PC_TexFormat_To_D3DFORMAT[12]
|
|||
D3DFMT_DXT1,//PC_TEX_FMT_DXT1
|
||||
D3DFMT_DXT3,//PC_TEX_FMT_DXT3
|
||||
D3DFMT_DXT5,//PC_TEX_FMT_DXT5
|
||||
D3DFMT_R32F,//PC_TEX_FMT_R32
|
||||
D3DFMT_R32F,//PC_TEX_FMT_R_FLOAT
|
||||
D3DFMT_A16B16G16R16F, //PC_TEX_FMT_RGBA16_FLOAT
|
||||
D3DFMT_A32B32G32R32F,//PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
|
||||
static const u32 PC_TexFormat_To_Buffer_Index[12]
|
||||
static const u32 PC_TexFormat_To_Buffer_Index[14]
|
||||
{
|
||||
0,//PC_TEX_FMT_NONE
|
||||
0,//PC_TEX_FMT_BGRA32
|
||||
|
@ -67,10 +69,12 @@ static const u32 PC_TexFormat_To_Buffer_Index[12]
|
|||
3,//PC_TEX_FMT_DXT1
|
||||
4,//PC_TEX_FMT_DXT3
|
||||
5,//PC_TEX_FMT_DXT5
|
||||
6,//PC_TEX_FMT_R32
|
||||
6,//PC_TEX_FMT_R_FLOAT
|
||||
7,//PC_TEX_FMT_RGBA16_FLOAT
|
||||
8,//PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
|
||||
#define MEM_TEXTURE_POOL_SIZE 6
|
||||
#define MEM_TEXTURE_POOL_SIZE 9
|
||||
static LPDIRECT3DTEXTURE9 s_memPoolTexture[MEM_TEXTURE_POOL_SIZE];
|
||||
static u32 s_memPoolTextureW[MEM_TEXTURE_POOL_SIZE];
|
||||
static u32 s_memPoolTextureH[MEM_TEXTURE_POOL_SIZE];
|
||||
|
|
|
@ -223,11 +223,21 @@ void TextureCache::TCacheEntry::SetFormat()
|
|||
gl_type = 0;
|
||||
compressed = true;
|
||||
break;
|
||||
case PC_TEX_FMT_R32:
|
||||
case PC_TEX_FMT_R_FLOAT:
|
||||
gl_format = GL_DEPTH_COMPONENT32F;
|
||||
gl_iformat = GL_DEPTH_COMPONENT;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
compressed = true;
|
||||
compressed = false;
|
||||
case PC_TEX_FMT_RGBA16_FLOAT:
|
||||
gl_format = GL_RGBA16F;
|
||||
gl_iformat = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
compressed = false;
|
||||
case PC_TEX_FMT_RGBA_FLOAT:
|
||||
gl_format = GL_RGBA32F;
|
||||
gl_iformat = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
compressed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ void TextureCache::ScaleTextureRectangle(TCacheEntry* dst_texture,
|
|||
|
||||
TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config)
|
||||
{
|
||||
static const VkFormat PC_TexFormat_To_VkFormat[12]
|
||||
static const VkFormat PC_TexFormat_To_VkFormat[]
|
||||
{
|
||||
VK_FORMAT_R8G8B8A8_UNORM,//PC_TEX_FMT_NONE
|
||||
VK_FORMAT_R8G8B8A8_UNORM,//PC_TEX_FMT_BGRA32
|
||||
|
@ -244,7 +244,9 @@ TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntry
|
|||
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,//PC_TEX_FMT_DXT1
|
||||
VK_FORMAT_BC2_UNORM_BLOCK,//PC_TEX_FMT_DXT3
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,//PC_TEX_FMT_DXT5
|
||||
VK_FORMAT_R32_SFLOAT,//PC_TEX_FMT_R32
|
||||
VK_FORMAT_R32_SFLOAT,//PC_TEX_FMT_R_FLOAT
|
||||
VK_FORMAT_R16G16B16A16_SFLOAT,//PC_TEX_FMT_RGBA16_FLOAT
|
||||
VK_FORMAT_R32G32B32A32_SFLOAT,//PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
// Determine image usage, we need to flag as an attachment if it can be used as a rendertarget.
|
||||
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
|
@ -301,7 +303,7 @@ TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntry
|
|||
VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_VIEW_TYPE_2D_ARRAY, VK_IMAGE_TILING_OPTIMAL, usage);
|
||||
}
|
||||
TCacheEntry* entry = new TCacheEntry(config, std::move(texture), std::move(nrmtexture), framebuffer);
|
||||
entry->compressed = config.pcformat >= PC_TEX_FMT_DXT1 && config.pcformat < PC_TEX_FMT_R32;
|
||||
entry->compressed = config.pcformat >= PC_TEX_FMT_DXT1 && config.pcformat < PC_TEX_FMT_R_FLOAT;
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
|
@ -522,6 +522,7 @@ bool PostProcessingShaderConfiguration::ParsePassBlock(const std::string& dirnam
|
|||
{
|
||||
RenderPass pass;
|
||||
pass.output_scale = 1.0f;
|
||||
pass.output_format = PC_TexFormat::PC_TEX_FMT_RGBA32;
|
||||
|
||||
for (const auto& option : block.m_options)
|
||||
{
|
||||
|
@ -537,6 +538,26 @@ bool PostProcessingShaderConfiguration::ParsePassBlock(const std::string& dirnam
|
|||
if (pass.output_scale <= 0.0f)
|
||||
return false;
|
||||
}
|
||||
else if (key == "OutputFormat")
|
||||
{
|
||||
if (value == "R32_FLOAT")
|
||||
{
|
||||
pass.output_format = PC_TexFormat::PC_TEX_FMT_R_FLOAT;
|
||||
}
|
||||
else if (value == "RGBA16_FLOAT")
|
||||
{
|
||||
pass.output_format = PC_TexFormat::PC_TEX_FMT_RGBA16_FLOAT;
|
||||
}
|
||||
else if (value == "RGBA32_FLOAT")
|
||||
{
|
||||
pass.output_format = PC_TexFormat::PC_TEX_FMT_RGBA_FLOAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else if (key == "OutputScaleNative")
|
||||
{
|
||||
TryParse(value, &pass.output_scale);
|
||||
|
@ -1155,7 +1176,7 @@ bool PostProcessingShader::ResizeOutputTextures(const TargetSize& new_size)
|
|||
config.pcformat = PC_TexFormat::PC_TEX_FMT_RGBA32;
|
||||
if (i < static_cast<size_t>(frameoutput.color_count))
|
||||
m_prev_frame_texture[i].color_frame = g_texture_cache->AllocateTexture(config);
|
||||
config.pcformat = PC_TexFormat::PC_TEX_FMT_R32;
|
||||
config.pcformat = PC_TexFormat::PC_TEX_FMT_R_FLOAT;
|
||||
if (i < static_cast<size_t>(frameoutput.depth_count))
|
||||
m_prev_frame_texture[i].depth_frame = g_texture_cache->AllocateTexture(config);
|
||||
}
|
||||
|
@ -1174,6 +1195,8 @@ bool PostProcessingShader::ResizeOutputTextures(const TargetSize& new_size)
|
|||
|
||||
config.width = pass.output_size.width;
|
||||
config.height = pass.output_size.height;
|
||||
// Last pass output is always RGBA32
|
||||
config.pcformat = pass_index < m_passes.size() - 1 ? pass.output_format : PC_TexFormat::PC_TEX_FMT_RGBA32;
|
||||
pass.output_texture = g_texture_cache->AllocateTexture(config);
|
||||
}
|
||||
m_internal_size = new_size;
|
||||
|
@ -1585,7 +1608,7 @@ bool PostProcessor::ResizeCopyBuffers(const TargetSize& size, int layers)
|
|||
config.rendertarget = true;
|
||||
config.layers = layers;
|
||||
m_color_copy_texture = g_texture_cache->AllocateTexture(config);
|
||||
config.pcformat = PC_TexFormat::PC_TEX_FMT_R32;
|
||||
config.pcformat = PC_TexFormat::PC_TEX_FMT_R_FLOAT;
|
||||
m_depth_copy_texture = g_texture_cache->AllocateTexture(config);
|
||||
if (m_color_copy_texture && m_depth_copy_texture)
|
||||
{
|
||||
|
|
|
@ -123,6 +123,7 @@ public:
|
|||
std::vector<Input> inputs;
|
||||
std::string entry_point;
|
||||
float output_scale;
|
||||
PC_TexFormat output_format;
|
||||
std::vector<const ConfigurationOption*> dependent_options;
|
||||
|
||||
void GetInputLocations(
|
||||
|
@ -357,6 +358,7 @@ protected:
|
|||
TextureCacheBase::TCacheEntryBase* output_texture{};
|
||||
TargetSize output_size{};
|
||||
float output_scale{};
|
||||
PC_TexFormat output_format = PC_TexFormat::PC_TEX_FMT_RGBA32;
|
||||
|
||||
bool enabled{};
|
||||
};
|
||||
|
|
|
@ -85,7 +85,9 @@ enum PC_TexFormat
|
|||
PC_TEX_FMT_DXT1,
|
||||
PC_TEX_FMT_DXT3,
|
||||
PC_TEX_FMT_DXT5,
|
||||
PC_TEX_FMT_R32,
|
||||
PC_TEX_FMT_R_FLOAT,
|
||||
PC_TEX_FMT_RGBA16_FLOAT,
|
||||
PC_TEX_FMT_RGBA_FLOAT
|
||||
};
|
||||
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, u32 width, u32 height, u32 texformat, u32 tlutaddr, TlutFormat tlutfmt, bool rgbaOnly = false, bool compressed_supported = false);
|
||||
PC_TexFormat GetPC_TexFormat(u32 texformat, TlutFormat tlutfmt, bool compressed_supported = false);
|
||||
|
|
Loading…
Reference in a new issue