Playstation 5 fixes (#733)
This commit is contained in:
@@ -309,6 +309,8 @@ wi::vector<ShaderEntry> shaders = {
|
||||
{"shadowGS_emulation", wi::graphics::ShaderStage::GS },
|
||||
{"shadowGS_alphatest_emulation", wi::graphics::ShaderStage::GS },
|
||||
{"shadowGS_transparent_emulation", wi::graphics::ShaderStage::GS },
|
||||
{"objectGS_primitiveID_emulation", wi::graphics::ShaderStage::GS },
|
||||
{"objectGS_primitiveID_emulation_alphatest", wi::graphics::ShaderStage::GS },
|
||||
{"voxelGS", wi::graphics::ShaderStage::GS },
|
||||
{"objectGS_voxelizer", wi::graphics::ShaderStage::GS },
|
||||
{"objectVS_simple", wi::graphics::ShaderStage::VS },
|
||||
@@ -536,9 +538,9 @@ int main(int argc, char* argv[])
|
||||
// if shader format cannot support shader model, then we cancel the task without returning error
|
||||
return;
|
||||
}
|
||||
if (input.minshadermodel >= ShaderModel::SM_6_5 && target.format == ShaderFormat::PS5)
|
||||
if (target.format == ShaderFormat::PS5 && (input.minshadermodel >= ShaderModel::SM_6_5 || input.stage == ShaderStage::MS))
|
||||
{
|
||||
// TODO PS5 raytracing
|
||||
// TODO PS5 raytracing, mesh shader
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,17 @@ using int4 = XMINT4;
|
||||
#define PUSHCONSTANT(name, type) ConstantBuffer<type> name : register(b999)
|
||||
#endif // __PSSL__
|
||||
|
||||
namespace wi
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
inline uint AlignTo(uint value, uint alignment)
|
||||
{
|
||||
return ((value + alignment - 1u) / alignment) * alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
struct IndirectDrawArgsInstanced
|
||||
@@ -67,6 +78,11 @@ struct IndirectDispatchArgs
|
||||
uint ThreadGroupCountZ;
|
||||
};
|
||||
|
||||
#if defined(__SCE__) || defined(__PSSL__)
|
||||
static const uint IndirectDispatchArgsAlignment = 32u;
|
||||
#else
|
||||
static const uint IndirectDispatchArgsAlignment = 4u;
|
||||
#endif // __SCE__ || __PSSL__
|
||||
|
||||
#if !defined(__PSSL__) && !defined(__SCE__)
|
||||
// Common buffers:
|
||||
|
||||
@@ -96,8 +96,8 @@ static const uint THREADCOUNT_EMIT = 256;
|
||||
static const uint THREADCOUNT_MESH_SHADER = 32;
|
||||
|
||||
static const uint ARGUMENTBUFFER_OFFSET_DISPATCHEMIT = 0;
|
||||
static const uint ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION = ARGUMENTBUFFER_OFFSET_DISPATCHEMIT + (3 * 4);
|
||||
static const uint ARGUMENTBUFFER_OFFSET_DRAWPARTICLES = ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION + (3 * 4);
|
||||
static const uint ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION = wi::graphics::AlignTo(ARGUMENTBUFFER_OFFSET_DISPATCHEMIT + (3 * 4), IndirectDispatchArgsAlignment);
|
||||
static const uint ARGUMENTBUFFER_OFFSET_DRAWPARTICLES = wi::graphics::AlignTo(ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION + (3 * 4), IndirectDispatchArgsAlignment);
|
||||
|
||||
|
||||
// If this is not defined, SPH will be resolved as N-body simulation (O(n^2) complexity)
|
||||
|
||||
@@ -413,6 +413,9 @@ struct ShaderTypeBin
|
||||
uint dispatchY;
|
||||
uint dispatchZ;
|
||||
uint shaderType;
|
||||
#if defined(__SCE__) || defined(__PSSL_)
|
||||
uint4 padding; // 32-byte alignment
|
||||
#endif // __SCE__ || __PSSL__
|
||||
};
|
||||
static const uint SHADERTYPE_BIN_COUNT = 10;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ static const uint SURFEL_STATS_OFFSET_RAYCOUNT = SURFEL_STATS_OFFSET_CELLALLOCAT
|
||||
static const uint SURFEL_STATS_OFFSET_SHORTAGE = SURFEL_STATS_OFFSET_RAYCOUNT + 4;
|
||||
static const uint SURFEL_STATS_SIZE = SURFEL_STATS_OFFSET_SHORTAGE + 4;
|
||||
static const uint SURFEL_INDIRECT_OFFSET_ITERATE = 0;
|
||||
static const uint SURFEL_INDIRECT_OFFSET_RAYTRACE = SURFEL_INDIRECT_OFFSET_ITERATE + 4 * 3;
|
||||
static const uint SURFEL_INDIRECT_OFFSET_INTEGRATE = SURFEL_INDIRECT_OFFSET_RAYTRACE + 4 * 3;
|
||||
static const uint SURFEL_INDIRECT_OFFSET_RAYTRACE = wi::graphics::AlignTo(SURFEL_INDIRECT_OFFSET_ITERATE + 4 * 3, IndirectDispatchArgsAlignment);
|
||||
static const uint SURFEL_INDIRECT_OFFSET_INTEGRATE = wi::graphics::AlignTo(SURFEL_INDIRECT_OFFSET_RAYTRACE + 4 * 3, IndirectDispatchArgsAlignment);
|
||||
static const uint SURFEL_INDIRECT_SIZE = SURFEL_INDIRECT_OFFSET_INTEGRATE + 4 * 3;
|
||||
static const uint SURFEL_INDIRECT_NUMTHREADS = 32;
|
||||
static const float SURFEL_TARGET_COVERAGE = 0.5f; // how many surfels should affect a pixel fully, higher values will increase quality and cost
|
||||
|
||||
@@ -402,6 +402,8 @@
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)objectGS_primitiveID_emulation.hlsl" />
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)objectGS_primitiveID_emulation_alphatest.hlsl" />
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)shadowGS_alphatest_emulation.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||
|
||||
@@ -1109,6 +1109,12 @@
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)hairparticlePS_shadow.hlsl">
|
||||
<Filter>PS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)objectGS_primitiveID_emulation.hlsl">
|
||||
<Filter>GS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)objectGS_primitiveID_emulation_alphatest.hlsl">
|
||||
<Filter>GS</Filter>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)ShaderInterop.h">
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
// Modified version of: https://github.com/knarkowicz/GPURealTimeBC6H/blob/master/bin/compress.hlsl
|
||||
#include "globals.hlsli"
|
||||
|
||||
#ifdef __PSSL__
|
||||
// TODO: register spilling issue
|
||||
#pragma warning (disable:7203)
|
||||
#endif // __PSSL__
|
||||
|
||||
// Whether to use P2 modes (4 endpoints) for compression. Slow, but improves quality.
|
||||
#ifdef COMPRESS_CUBEMAP
|
||||
#define ENCODE_P2 0
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include "hairparticleHF.hlsli"
|
||||
#include "ShaderInterop_HairParticle.h"
|
||||
|
||||
#ifdef __PSSL__
|
||||
#pragma PSSL_target_output_format (target 0 FMT_32_R)
|
||||
#endif // __PSSL__
|
||||
|
||||
uint main(VertexToPixel input, out uint coverage : SV_Coverage) : SV_Target
|
||||
{
|
||||
ShaderMaterial material = HairGetMaterial();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "globals.hlsli"
|
||||
// This geometry shader is intended as fallback support when GPU doesn't support SV_PrimitiveID input to pixel shader
|
||||
|
||||
struct GSInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float clip : SV_ClipDistance0;
|
||||
uint instanceIndex : INSTANCEINDEX;
|
||||
#ifdef ALPHATEST
|
||||
nointerpolation float dither : DITHER;
|
||||
float4 uvsets : UVSETS;
|
||||
#endif // ALPHATEST
|
||||
};
|
||||
|
||||
struct GSOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float clip : SV_ClipDistance0;
|
||||
uint instanceIndex : INSTANCEINDEX;
|
||||
#ifdef ALPHATEST
|
||||
nointerpolation float dither : DITHER;
|
||||
float4 uvsets : UVSETS;
|
||||
#endif // ALPHATEST
|
||||
uint primitiveID : PRIMITIVEID;
|
||||
};
|
||||
|
||||
[maxvertexcount(3)]
|
||||
void main(
|
||||
triangle GSInput input[3],
|
||||
in uint primitiveID : SV_PrimitiveID,
|
||||
inout TriangleStream<GSOutput> output
|
||||
)
|
||||
{
|
||||
for (uint i = 0; i < 3; i++)
|
||||
{
|
||||
GSOutput element;
|
||||
element.pos = input[i].pos;
|
||||
element.clip = input[i].clip;
|
||||
element.instanceIndex = input[i].instanceIndex;
|
||||
#ifdef ALPHATEST
|
||||
element.dither = input[i].dither;
|
||||
element.uvsets = input[i].uvsets;
|
||||
#endif // ALPHATEST
|
||||
element.primitiveID = primitiveID;
|
||||
output.Append(element);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#define ALPHATEST
|
||||
#include "objectGS_primitiveID_emulation.hlsl"
|
||||
@@ -371,7 +371,6 @@ PixelInput main(VertexInput input)
|
||||
#endif // OBJECTSHADER_COMPILE_VS
|
||||
|
||||
|
||||
|
||||
#ifdef OBJECTSHADER_COMPILE_PS
|
||||
|
||||
// Possible switches:
|
||||
@@ -382,6 +381,10 @@ PixelInput main(VertexInput input)
|
||||
// PARALLAXOCCLUSIONMAPPING - include parallax occlusion mapping computation
|
||||
// WATER - include specialized water shader code
|
||||
|
||||
#if defined(__PSSL__) && defined(PREPASS)
|
||||
#pragma PSSL_target_output_format (target 0 FMT_32_R)
|
||||
#endif // __PSSL__ && PREPASS
|
||||
|
||||
#ifdef EARLY_DEPTH_STENCIL
|
||||
[earlydepthstencil]
|
||||
#endif // EARLY_DEPTH_STENCIL
|
||||
|
||||
@@ -6,7 +6,7 @@ inline float3 sample_shadow(float2 uv, float cmp)
|
||||
{
|
||||
[branch]
|
||||
if (GetFrame().texture_shadowatlas_index < 0)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
Texture2D texture_shadowatlas = bindless_textures[GetFrame().texture_shadowatlas_index];
|
||||
float3 shadow = texture_shadowatlas.SampleCmpLevelZero(sampler_cmp_depth, uv, cmp).r;
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace wi
|
||||
startup_script = true;
|
||||
Luna<wi::lua::Application_BindLua>::push_global(wi::lua::GetLuaState(), "main", this);
|
||||
Luna<wi::lua::Application_BindLua>::push_global(wi::lua::GetLuaState(), "application", this);
|
||||
wi::lua::RunFile("startup.lua");
|
||||
wi::lua::RunFile(wi::helper::GetCurrentPath() + "/startup.lua");
|
||||
}
|
||||
|
||||
if (!is_window_active && !wi::arguments::HasArgument("alwaysactive"))
|
||||
|
||||
@@ -192,6 +192,8 @@ namespace wi::enums
|
||||
GSTYPE_ENVMAP_SKY_EMULATION,
|
||||
GSTYPE_VOXELIZER,
|
||||
GSTYPE_VOXEL,
|
||||
GSTYPE_OBJECT_PRIMITIVEID_EMULATION,
|
||||
GSTYPE_OBJECT_PRIMITIVEID_EMULATION_ALPHATEST,
|
||||
|
||||
|
||||
// hull shaders
|
||||
|
||||
@@ -797,13 +797,13 @@ namespace wi::helper
|
||||
bool FileRead_Impl(const std::string& fileName, vector_interface<uint8_t, std::allocator<uint8_t>>& data)
|
||||
{
|
||||
#ifndef PLATFORM_UWP
|
||||
#ifdef SDL_FILESYSTEM_UNIX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_PS5)
|
||||
std::string filepath = fileName;
|
||||
std::replace(filepath.begin(), filepath.end(), '\\', '/'); // Linux cannot handle backslash in file path, need to convert it to forward slash
|
||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||
#else
|
||||
std::ifstream file(ToNativeString(fileName), std::ios::binary | std::ios::ate);
|
||||
#endif // SDL_FILESYSTEM_UNIX
|
||||
#endif // PLATFORM_LINUX || PLATFORM_PS5
|
||||
if (file.is_open())
|
||||
{
|
||||
size_t dataSize = (size_t)file.tellg();
|
||||
@@ -1010,12 +1010,12 @@ namespace wi::helper
|
||||
|
||||
std::string GetTempDirectoryPath()
|
||||
{
|
||||
#ifdef PLATFORM_XBOX
|
||||
#if defined(PLATFORM_XBOX) || defined(PLATFORM_PS5)
|
||||
return "";
|
||||
#else
|
||||
auto path = std::filesystem::temp_directory_path();
|
||||
return path.generic_u8string();
|
||||
#endif // PLATFORM_XBOX
|
||||
#endif // PLATFORM_XBOX || PLATFORM_PS5
|
||||
}
|
||||
|
||||
std::string GetCacheDirectoryPath()
|
||||
@@ -1040,8 +1040,12 @@ namespace wi::helper
|
||||
|
||||
std::string GetCurrentPath()
|
||||
{
|
||||
#ifdef PLATFORM_PS5
|
||||
return "/app0";
|
||||
#else
|
||||
auto path = std::filesystem::current_path();
|
||||
return path.generic_u8string();
|
||||
#endif // PLATFORM_PS5
|
||||
}
|
||||
|
||||
void FileDialog(const FileDialogParams& params, std::function<void(std::string fileName)> onSuccess)
|
||||
|
||||
@@ -441,6 +441,19 @@ SHADERTYPE GetGSTYPE(RENDERPASS renderPass, bool alphatest, bool transparent)
|
||||
break;
|
||||
#endif // VOXELIZATION_GEOMETRY_SHADER_ENABLED
|
||||
|
||||
case RENDERPASS_PREPASS:
|
||||
#ifdef PLATFORM_PS5
|
||||
if (alphatest)
|
||||
{
|
||||
realGS = GSTYPE_OBJECT_PRIMITIVEID_EMULATION_ALPHATEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
realGS = GSTYPE_OBJECT_PRIMITIVEID_EMULATION;
|
||||
}
|
||||
#endif // PLATFORM_PS5
|
||||
break;
|
||||
|
||||
case RENDERPASS_ENVMAPCAPTURE:
|
||||
if (device->CheckCapability(GraphicsDeviceCapability::RENDERTARGET_AND_VIEWPORT_ARRAYINDEX_WITHOUT_GS))
|
||||
break;
|
||||
@@ -868,6 +881,10 @@ void LoadShaders()
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::GS, shaders[GSTYPE_VOXELIZER], "objectGS_voxelizer.cso"); });
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::GS, shaders[GSTYPE_VOXEL], "voxelGS.cso"); });
|
||||
|
||||
#ifdef PLATFORM_PS5
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::GS, shaders[GSTYPE_OBJECT_PRIMITIVEID_EMULATION], "objectGS_primitiveID_emulation.cso"); });
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::GS, shaders[GSTYPE_OBJECT_PRIMITIVEID_EMULATION_ALPHATEST], "objectGS_primitiveID_emulation_alphatest.cso"); });
|
||||
#endif // PLATFORM_PS5
|
||||
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_LUMINANCE_PASS1], "luminancePass1CS.cso"); });
|
||||
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_LUMINANCE_PASS2], "luminancePass2CS.cso"); });
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 273;
|
||||
const int revision = 274;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user