Skip to content

Commit

Permalink
Added support for Xbox Series X|S
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij authored Aug 5, 2023
1 parent e9eed3a commit 79cd98c
Show file tree
Hide file tree
Showing 40 changed files with 694 additions and 504 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ You can get the full source code by using Git version control and cloning https:
- Windows 10 or newer
- Linux
- UWP
- Xbox Series X|S

### How to build:

Expand Down Expand Up @@ -71,10 +72,13 @@ If you have questions or stuck, please use the `linux` communication channel on


#### UWP
To build for UWP platform, use the latest version of Visual Studio and the provided `WickedEngine.sln` solution file. The WickedEngine_UWP Project will build the engine for UWP platform as static library. The Template_UWP and Editor_UWP are two applications that will work on UWP platform that you can try. But first you must also build the binary shaders and embed them into the executable. To build and embed shaders, run the `OfflineShaderCompiler` projects with the `hlsl6 shaderdump` command line arguments. Then Rebuild the WickedEngine_UWP to create the engine with embedded shaders included. Now you can build an UWP application and run it on PC or XBOX.
To build for UWP platform, use the latest version of Visual Studio and the provided `WickedEngine.sln` solution file. The WickedEngine_UWP Project will build the engine for UWP platform as static library. The Template_UWP and Editor_UWP are two applications that will work on UWP platform that you can try. But first you must also build the binary shaders and embed them into the executable. To build and embed shaders, run the `OfflineShaderCompiler` projects with the `hlsl6 shaderdump` command line arguments. Then Rebuild the WickedEngine_UWP to create the engine with embedded shaders included. Now you can build an UWP application and run it on PC or Xbox.

##### XBOX UWP
To run the UWP application on XBOX, enable developer mode on your XBOX, and choose "Remote Machine" as a debugging target in Visual Studio. Enter the IP address of the XBOX into the Machine Name field of debugging project settings (make sure that you are modifying the debug settings for Remote Machine). The authentication mode should be set to "Universal (Unencrypted Protocol)" and upon launching the application from Visual Studio, you will need to enter the security PIN that you can view on the XBOX developer settings.
- To run the UWP application on **Xbox**, enable developer mode on your Xbox, and choose "Remote Machine" as a debugging target in Visual Studio. Enter the IP address of the Xbox into the Machine Name field of debugging project settings (make sure that you are modifying the debug settings for Remote Machine). The authentication mode should be set to "Universal (Unencrypted Protocol)" and upon launching the application from Visual Studio, you will need to enter the security PIN that you can view on the Xbox developer settings.<br/>
**Note that to utilize the full performance of Xbox Series, it is required to build with the native Xbox SDK build tools**

#### Xbox Series (Native)
To build for Xbox Series natively, download and install the Xbox SDK from your Xbox developer account, and create a new Visual Studio solution platform targetting the Xbox Series hardware. Xbox specific extension files required for building will be provided for registered Xbox developers on request.


### Examples:
Expand Down
12 changes: 8 additions & 4 deletions WickedEngine/WickedEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@
#include "wiLocalization.h"
#include "wiVideo.h"

#ifdef _WIN32
#ifdef PLATFORM_WINDOWS_DESKTOP
#pragma comment(lib,"WickedEngine_Windows.lib")
#endif // PLATFORM_WINDOWS_DESKTOP

#ifdef PLATFORM_UWP
#pragma comment(lib,"WickedEngine_UWP.lib")
#else
#pragma comment(lib,"WickedEngine_Windows.lib")
#endif // PLATFORM_UWP
#endif // _WIN32

#ifdef PLATFORM_XBOX
#pragma comment(lib,"WickedEngine_XBOX.lib")
#endif // PLATFORM_XBOX


// After version 0.59.11, namespaces were refactored into nested namespaces under the wi:: root namespace.
Expand Down
1 change: 0 additions & 1 deletion WickedEngine/WickedEngine_SOURCE.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)wiLocalization.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)wiPhysics_BindLua.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)wiRenderPath3D_PathTracing.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Utility\D3D12MemAlloc.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Utility\samplerBlueNoiseErrorDistribution_128x128_OptimizedFor_2d2d2d2d_1spp.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Utility\spirv_reflect.c">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
Expand Down
3 changes: 0 additions & 3 deletions WickedEngine/WickedEngine_SOURCE.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1802,9 +1802,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)wiNetwork_UWP.cpp">
<Filter>ENGINE\Network</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)Utility\D3D12MemAlloc.cpp">
<Filter>UTILITY</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)wiInput.cpp">
<Filter>ENGINE\Input</Filter>
</ClCompile>
Expand Down
6 changes: 6 additions & 0 deletions WickedEngine/offlineshadercompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ int main(int argc, char* argv[])
std::cout << "\thlsl5 : \t\tCompile shaders to hlsl5 (dx11) format (using d3dcompiler)\n";
std::cout << "\thlsl6 : \t\tCompile shaders to hlsl6 (dx12) format (using dxcompiler)\n";
std::cout << "\tspirv : \t\tCompile shaders to spirv (vulkan) format (using dxcompiler)\n";
std::cout << "\thlsl6_xs : \t\tCompile shaders to hlsl6 Xbox Series native (dx12) format (using dxcompiler_xs)\n";
std::cout << "\trebuild : \t\tAll shaders will be rebuilt, regardless if they are outdated or not\n";
std::cout << "\tdisable_optimization : \tShaders will be compiled without optimizations (this will improve shader debuggability, but reduce performance)\n";
std::cout << "\tstrip_reflection : \tReflection will be stripped from shader binary to reduce file size (this will reduce shader debuggability)\n";
Expand All @@ -388,6 +389,11 @@ int main(int argc, char* argv[])
targets.push_back({ ShaderFormat::SPIRV, "shaders/spirv/" });
std::cout << "spirv ";
}
if (wi::arguments::HasArgument("hlsl6_xs"))
{
targets.push_back({ ShaderFormat::HLSL6_XS, "shaders/hlsl6_xs/" });
std::cout << "hlsl6_xs ";
}

if (wi::arguments::HasArgument("shaderdump"))
{
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/shaders/circlePS.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "globals.hlsli"

struct GSOutput
{
float4 pos : SV_Position;
Expand Down
14 changes: 8 additions & 6 deletions WickedEngine/shaders/ddgi_raytraceCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
ray.Direction = normalize(mul(random_orientation, spherical_fibonacci(rayIndex, push.rayCount)));

#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_CULL_BACK_FACING_TRIANGLES, // uint RayFlags
RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE, // uint RayFlags
push.instanceInclusionMask, // uint InstanceInclusionMask
ray // RayDesc Ray
);
Expand Down Expand Up @@ -243,7 +242,10 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
#ifdef RTAPI
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
);
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/shaders/envMapGS_emulation.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "globals.hlsli"
// This geometry shader is intended as fallback support when GPU doesn't support writing to
// SV_RenderTargetArrayIndex from Vertex Shader stage

Expand Down
1 change: 1 addition & 0 deletions WickedEngine/shaders/envMap_skyGS_emulation.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "globals.hlsli"
// This geometry shader is intended as fallback support when GPU doesn't support writing to
// SV_RenderTargetArrayIndex from Vertex Shader stage

Expand Down
8 changes: 4 additions & 4 deletions WickedEngine/shaders/objectHF.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ struct PixelInput
{
precise float4 pos : SV_POSITION;

#ifdef OBJECTSHADER_USE_INSTANCEINDEX
uint instanceIndex : INSTANCEINDEX;
#endif // OBJECTSHADER_USE_INSTANCEINDEX

#ifdef OBJECTSHADER_USE_CLIPPLANE
float clip : SV_ClipDistance0;
#endif // OBJECTSHADER_USE_CLIPPLANE

#ifdef OBJECTSHADER_USE_INSTANCEINDEX
uint instanceIndex : INSTANCEINDEX;
#endif // OBJECTSHADER_USE_INSTANCEINDEX

#ifdef OBJECTSHADER_USE_DITHERING
nointerpolation float dither : DITHER;
#endif // OBJECTSHADER_USE_DITHERING
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/shaders/oceanSurfaceSimplePS.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "globals.hlsli"

float4 main() : SV_TARGET
{
return float4(1.0f, 1.0f, 1.0f, 1.0f);
Expand Down
8 changes: 3 additions & 5 deletions WickedEngine/shaders/raytraceCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
float4 additive_dist = float4(0, 0, 0, FLT_MAX);

#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES
> q;
wiRayQuery q;

uint flags = 0;
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES;
#ifdef RAY_BACKFACE_CULLING
flags |= RAY_FLAG_CULL_BACK_FACING_TRIANGLES;
#endif // RAY_BACKFACE_CULLING
Expand Down Expand Up @@ -317,7 +315,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)

#ifdef RTAPI

uint flags = RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
if (bounce > ANYTHIT_CUTOFF_AFTER_BOUNCE_COUNT)
{
flags |= RAY_FLAG_FORCE_OPAQUE;
Expand Down
6 changes: 6 additions & 0 deletions WickedEngine/shaders/raytracingHF.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include "ShaderInterop_BVH.h"
#include "brdf.hlsli"

#ifdef __XBOX_SCARLETT
#include "raytracingHF_XBOX.hlsli"
#else
#define wiRayQuery RayQuery<0>
#endif // __XBOX_SCARLETT

#ifdef HLSL5
struct RayDesc
{
Expand Down
6 changes: 2 additions & 4 deletions WickedEngine/shaders/renderlightmapPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ float4 main(Input input) : SV_TARGET
for (uint bounce = 0; bounce < bounces; ++bounce)
{
#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES
> q;
wiRayQuery q;
#endif // RTAPI

surface.P = ray.Origin;
Expand Down Expand Up @@ -158,7 +156,7 @@ float4 main(Input input) : SV_TARGET
newRay.Direction = L + max3(surface.sss);

#ifdef RTAPI
uint flags = RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
if (bounce > ANYTHIT_CUTOFF_AFTER_BOUNCE_COUNT)
{
flags |= RAY_FLAG_FORCE_OPAQUE;
Expand Down
8 changes: 3 additions & 5 deletions WickedEngine/shaders/rtaoCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint3 GTid :
float shadow = 0;

#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
0, // uint RayFlags
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
asuint(postprocess.params1.x), // uint InstanceInclusionMask
ray // RayDesc Ray
);
Expand Down
8 changes: 3 additions & 5 deletions WickedEngine/shaders/rtdiffuseCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ void main(uint2 DTid : SV_DispatchThreadID)

float4 additive_dist = float4(0, 0, 0, FLT_MAX);

RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
0, // uint RayFlags
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES, // uint RayFlags
asuint(postprocess.params1.x), // uint InstanceInclusionMask
ray // RayDesc Ray
);
Expand Down
8 changes: 3 additions & 5 deletions WickedEngine/shaders/rtreflectionCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ void main(uint2 DTid : SV_DispatchThreadID)

float4 additive_dist = float4(0, 0, 0, FLT_MAX);

RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
0, // uint RayFlags
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES, // uint RayFlags
asuint(postprocess.params1.x), // uint InstanceInclusionMask
ray // RayDesc Ray
);
Expand Down
13 changes: 7 additions & 6 deletions WickedEngine/shaders/screenspaceshadowCS.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//#define BRDF_NDOTL_BIAS 0.1
#define RAYTRACING_HINT_COHERENT_RAYS // xbox
#include "globals.hlsli"
#include "ShaderInterop_Postprocess.h"
#include "raytracingHF.hlsli"
Expand Down Expand Up @@ -205,19 +206,19 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint3 GTid :
ray.Direction = L + max3(surface.sss);

#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
0, // uint RayFlags
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES |
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
asuint(postprocess.params1.x), // uint InstanceInclusionMask
ray // RayDesc Ray
);
while (q.Proceed())
{
if(q.CandidateType() != CANDIDATE_NON_OPAQUE_TRIANGLE) // see xbox coherent ray traversal documentation
continue;
PrimitiveID prim;
prim.primitiveIndex = q.CandidatePrimitiveIndex();
prim.instanceIndex = q.CandidateInstanceID();
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/shaders/shadowGS_alphatest_emulation.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "globals.hlsli"
// This geometry shader is intended as fallback support when GPU doesn't support writing to
// SV_ViewportArrayIndex from Vertex Shader stage

Expand Down
1 change: 1 addition & 0 deletions WickedEngine/shaders/shadowGS_emulation.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "globals.hlsli"
// This geometry shader is intended as fallback support when GPU doesn't support writing to
// SV_ViewportArrayIndex from Vertex Shader stage

Expand Down
1 change: 1 addition & 0 deletions WickedEngine/shaders/shadowGS_transparent_emulation.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "globals.hlsli"
// This geometry shader is intended as fallback support when GPU doesn't support writing to
// SV_ViewportArrayIndex from Vertex Shader stage

Expand Down
9 changes: 5 additions & 4 deletions WickedEngine/shaders/surfel_raytraceCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ void main(uint3 DTid : SV_DispatchThreadID)
rayData.direction = ray.Direction;

#ifdef RTAPI
RayQuery<
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE
> q;
wiRayQuery q;
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE |
RAY_FLAG_CULL_BACK_FACING_TRIANGLES, // uint RayFlags
push.instanceInclusionMask, // uint InstanceInclusionMask
ray // RayDesc Ray
Expand Down Expand Up @@ -237,6 +236,8 @@ void main(uint3 DTid : SV_DispatchThreadID)
#ifdef RTAPI
q.TraceRayInline(
scene_acceleration_structure, // RaytracingAccelerationStructure AccelerationStructure
RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES |
RAY_FLAG_FORCE_OPAQUE |
RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, // uint RayFlags
0xFF, // uint InstanceInclusionMask
newRay // RayDesc Ray
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/shaders/vertexcolorPS.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "globals.hlsli"

struct VertexToPixel
{
float4 pos : SV_POSITION;
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/shaders/voxelPS.hlsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "globals.hlsli"

float4 main(float4 pos : SV_Position, float4 col : TEXCOORD) : SV_Target
{
return col;
Expand Down
13 changes: 12 additions & 1 deletion WickedEngine/wiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,11 @@ namespace wi
else if (use_dx12)
{
#ifdef WICKEDENGINE_BUILD_DX12
#ifdef PLATFORM_XBOX
wi::renderer::SetShaderPath(wi::renderer::GetShaderPath() + "hlsl6_xs/");
#else
wi::renderer::SetShaderPath(wi::renderer::GetShaderPath() + "hlsl6/");
#endif // PLATFORM_XBOX
graphicsDevice = std::make_unique<GraphicsDevice_DX12>(validationMode, preference);
#endif
}
Expand All @@ -585,7 +589,14 @@ namespace wi
{
// initialize for the first time
desc.buffer_count = 3;
desc.format = Format::R10G10B10A2_UNORM;
if (graphicsDevice->CheckCapability(GraphicsDeviceCapability::R9G9B9E5_SHAREDEXP_RENDERABLE))
{
desc.format = Format::R9G9B9E5_SHAREDEXP;
}
else
{
desc.format = Format::R10G10B10A2_UNORM;
}
}
desc.width = canvas.GetPhysicalWidth();
desc.height = canvas.GetPhysicalHeight();
Expand Down
Loading

0 comments on commit 79cd98c

Please sign in to comment.