Improve GPU constant buffers structures definitions to properly align on new Clang

This commit is contained in:
Wojtek Figat
2024-06-02 09:52:10 +02:00
parent 2492d0b38f
commit 1e86eff2d3
40 changed files with 57 additions and 76 deletions

View File

@@ -98,7 +98,7 @@
#endif #endif
#define PACK_STRUCT(__Declaration__) PACK_BEGIN() __Declaration__ PACK_END() #define PACK_STRUCT(_declaration) PACK_BEGIN() _declaration PACK_END()
// C++ 17 // C++ 17
#if __cplusplus >= 201703L #if __cplusplus >= 201703L

View File

@@ -125,7 +125,7 @@ PACK_STRUCT(struct Vertex {
Color32 Color; Color32 Color;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Matrix ViewProjection; Matrix ViewProjection;
Float2 Padding; Float2 Padding;
float ClipPosZBias; float ClipPosZBias;

View File

@@ -85,3 +85,6 @@
#undef GPU_ENABLE_ASSERTION #undef GPU_ENABLE_ASSERTION
#define GPU_ENABLE_ASSERTION 0 #define GPU_ENABLE_ASSERTION 0
#endif #endif
// Helper macro for defining shader structures wrappers in C++ that match HLSL constant buffers
#define GPU_CB_STRUCT(_declaration) ALIGN_BEGIN(GPU_SHADER_DATA_ALIGNMENT) PACK_BEGIN() struct _declaration PACK_END() ALIGN_END(GPU_SHADER_DATA_ALIGNMENT)

View File

@@ -12,8 +12,7 @@ class SkinnedModel;
struct RenderContext; struct RenderContext;
struct FloatR10G10B10A2; struct FloatR10G10B10A2;
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) QuadShaderData GPU_CB_STRUCT(QuadShaderData {
{
Float4 Color; Float4 Color;
}); });

View File

@@ -179,7 +179,7 @@ void ExponentialHeightFog::GetExponentialHeightFogData(const RenderView& view, S
result.VolumetricFogMaxDistance = VolumetricFogDistance; result.VolumetricFogMaxDistance = VolumetricFogDistance;
} }
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
ShaderExponentialHeightFogData ExponentialHeightFog; ShaderExponentialHeightFogData ExponentialHeightFog;
}); });

View File

@@ -17,7 +17,7 @@
#include "Engine/Serialization/Serialization.h" #include "Engine/Serialization/Serialization.h"
#include "Engine/Level/Scene/SceneRendering.h" #include "Engine/Level/Scene/SceneRendering.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Matrix WVP; Matrix WVP;
Float3 ViewOffset; Float3 ViewOffset;
float Padding; float Padding;

View File

@@ -13,7 +13,7 @@
#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUShader.h"
#include "Engine/Graphics/Shaders/GPUConstantBuffer.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) GPUParticlesData { GPU_CB_STRUCT(GPUParticlesData {
Matrix ViewProjectionMatrix; Matrix ViewProjectionMatrix;
Matrix InvViewProjectionMatrix; Matrix InvViewProjectionMatrix;
Matrix InvViewMatrix; Matrix InvViewMatrix;

View File

@@ -569,7 +569,7 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
#if COMPILE_WITH_GPU_PARTICLES #if COMPILE_WITH_GPU_PARTICLES
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) GPUParticlesSortingData { GPU_CB_STRUCT(GPUParticlesSortingData {
Float3 ViewPosition; Float3 ViewPosition;
uint32 ParticleCounterOffset; uint32 ParticleCounterOffset;
uint32 ParticleStride; uint32 ParticleStride;

View File

@@ -52,11 +52,11 @@
// True if enable downscaling when rendering blur // True if enable downscaling when rendering blur
const bool DownsampleForBlur = false; const bool DownsampleForBlur = false;
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Matrix ViewProjection; Matrix ViewProjection;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) BlurData { GPU_CB_STRUCT(BlurData {
Float2 InvBufferSize; Float2 InvBufferSize;
uint32 SampleCount; uint32 SampleCount;
float Dummy0; float Dummy0;

View File

@@ -20,7 +20,7 @@ class AmbientOcclusionPass : public RendererPass<AmbientOcclusionPass>
private: private:
// Packed shader constant buffer structure (this MUST match shader code) // Packed shader constant buffer structure (this MUST match shader code)
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ASSAOConstants { GPU_CB_STRUCT(ASSAOConstants {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
Float2 ViewportPixelSize; Float2 ViewportPixelSize;

View File

@@ -7,8 +7,7 @@
#include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/Graphics.h"
#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTask.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Float4 ScreenSize; Float4 ScreenSize;
}); });

View File

@@ -15,8 +15,7 @@ class SMAA : public RendererPass<SMAA>
{ {
private: private:
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Float4 RtSize; Float4 RtSize;
}); });

View File

@@ -11,8 +11,7 @@
#include "Engine/Renderer/GBufferPass.h" #include "Engine/Renderer/GBufferPass.h"
#include "Engine/Engine/Engine.h" #include "Engine/Engine/Engine.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Float2 ScreenSizeInv; Float2 ScreenSizeInv;
Float2 JitterInv; Float2 JitterInv;
float Sharpness; float Sharpness;

View File

@@ -61,8 +61,7 @@ protected:
bool Run() override; bool Run() override;
}; };
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
float First; float First;
float AtmosphereR; float AtmosphereR;
int AtmosphereLayer; int AtmosphereLayer;

View File

@@ -8,7 +8,7 @@
#include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderTargetPool.h"
#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTask.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Float4 ColorSaturationShadows; Float4 ColorSaturationShadows;
Float4 ColorContrastShadows; Float4 ColorContrastShadows;
Float4 ColorGammaShadows; Float4 ColorGammaShadows;

View File

@@ -11,8 +11,7 @@
/// <summary> /// <summary>
/// Structure that contains information about GBuffer for shaders. /// Structure that contains information about GBuffer for shaders.
/// </summary> /// </summary>
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderGBufferData GPU_CB_STRUCT(ShaderGBufferData {
{
Float4 ViewInfo; Float4 ViewInfo;
Float4 ScreenSize; Float4 ScreenSize;
Float3 ViewPos; Float3 ViewPos;
@@ -24,8 +23,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderGBufferData
/// <summary> /// <summary>
/// Structure that contains information about exponential height fog for shaders. /// Structure that contains information about exponential height fog for shaders.
/// </summary> /// </summary>
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderExponentialHeightFogData GPU_CB_STRUCT(ShaderExponentialHeightFogData {
{
Float3 FogInscatteringColor; Float3 FogInscatteringColor;
float FogMinOpacity; float FogMinOpacity;
@@ -49,8 +47,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderExponentialHeightFog
/// <summary> /// <summary>
/// Structure that contains information about atmosphere fog for shaders. /// Structure that contains information about atmosphere fog for shaders.
/// </summary> /// </summary>
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderAtmosphericFogData GPU_CB_STRUCT(ShaderAtmosphericFogData {
{
float AtmosphericFogDensityScale; float AtmosphericFogDensityScale;
float AtmosphericFogSunDiscScale; float AtmosphericFogSunDiscScale;
float AtmosphericFogDistanceScale; float AtmosphericFogDistanceScale;
@@ -71,7 +68,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderAtmosphericFogData
/// <summary> /// <summary>
/// Structure that contains information about light for shaders. /// Structure that contains information about light for shaders.
/// </summary> /// </summary>
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderLightData { GPU_CB_STRUCT(ShaderLightData {
Float2 SpotAngles; Float2 SpotAngles;
float SourceRadius; float SourceRadius;
float SourceLength; float SourceLength;
@@ -90,7 +87,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderLightData {
/// <summary> /// <summary>
/// Packed env probe data /// Packed env probe data
/// </summary> /// </summary>
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderEnvProbeData { GPU_CB_STRUCT(ShaderEnvProbeData {
Float4 Data0; // x - Position.x, y - Position.y, z - Position.z, w - unused Float4 Data0; // x - Position.x, y - Position.y, z - Position.z, w - unused
Float4 Data1; // x - Radius , y - 1 / Radius, z - Brightness, w - unused Float4 Data1; // x - Radius , y - 1 / Radius, z - Brightness, w - unused
}); });

View File

@@ -18,7 +18,7 @@
#define DOF_GRID_SIZE 450 #define DOF_GRID_SIZE 450
#define DOF_DEPTH_BLUR_FORMAT PixelFormat::R16G16_Float #define DOF_DEPTH_BLUR_FORMAT PixelFormat::R16G16_Float
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Float2 ProjectionAB; Float2 ProjectionAB;
float BokehDepthCullThreshold; float BokehDepthCullThreshold;
float BokehDepthCutoff; float BokehDepthCutoff;

View File

@@ -19,7 +19,7 @@
#include "Engine/Level/Scene/Scene.h" #include "Engine/Level/Scene/Scene.h"
#include "Engine/Level/Actors/StaticModel.h" #include "Engine/Level/Actors/StaticModel.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) LightmapUVsDensityMaterialShaderData { GPU_CB_STRUCT(LightmapUVsDensityMaterialShaderData {
Matrix ViewProjectionMatrix; Matrix ViewProjectionMatrix;
Matrix WorldMatrix; Matrix WorldMatrix;
Rectangle LightmapArea; Rectangle LightmapArea;

View File

@@ -12,7 +12,7 @@
#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTask.h"
#include "Engine/Renderer/DrawCall.h" #include "Engine/Renderer/DrawCall.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) VertexColorsMaterialShaderData { GPU_CB_STRUCT(VertexColorsMaterialShaderData {
Matrix ViewProjectionMatrix; Matrix ViewProjectionMatrix;
Matrix WorldMatrix; Matrix WorldMatrix;
}); });

View File

@@ -16,7 +16,7 @@
#include "Engine/Engine/Engine.h" #include "Engine/Engine/Engine.h"
#include "Engine/Engine/Time.h" #include "Engine/Engine/Time.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) EyeAdaptationData { GPU_CB_STRUCT(EyeAdaptationData {
float MinBrightness; float MinBrightness;
float MaxBrightness; float MaxBrightness;
float SpeedUp; float SpeedUp;

View File

@@ -21,7 +21,7 @@
#include "Engine/Level/Actors/Decal.h" #include "Engine/Level/Actors/Decal.h"
#include "Engine/Engine/Engine.h" #include "Engine/Engine/Engine.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) GBufferPassData{ GPU_CB_STRUCT(GBufferPassData {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
Float3 Dummy0; Float3 Dummy0;
int32 ViewMode; int32 ViewMode;

View File

@@ -41,8 +41,7 @@
#define DDGI_PROBE_UPDATE_BORDERS_GROUP_SIZE 8 #define DDGI_PROBE_UPDATE_BORDERS_GROUP_SIZE 8
#define DDGI_PROBE_CLASSIFY_GROUP_SIZE 32 #define DDGI_PROBE_CLASSIFY_GROUP_SIZE 32
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data0 GPU_CB_STRUCT(Data0 {
{
DynamicDiffuseGlobalIlluminationPass::ConstantsData DDGI; DynamicDiffuseGlobalIlluminationPass::ConstantsData DDGI;
GlobalSignDistanceFieldPass::ConstantsData GlobalSDF; GlobalSignDistanceFieldPass::ConstantsData GlobalSDF;
GlobalSurfaceAtlasPass::ConstantsData GlobalSurfaceAtlas; GlobalSurfaceAtlasPass::ConstantsData GlobalSurfaceAtlas;
@@ -54,8 +53,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data0
Int4 ProbeScrollClears[4]; Int4 ProbeScrollClears[4];
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data1 GPU_CB_STRUCT(Data1 {
{
// TODO: use push constants on Vulkan or root signature data on DX12 to reduce overhead of changing single DWORD // TODO: use push constants on Vulkan or root signature data on DX12 to reduce overhead of changing single DWORD
Float2 Padding1; Float2 Padding1;
uint32 CascadeIndex; uint32 CascadeIndex;

View File

@@ -13,8 +13,7 @@ class FLAXENGINE_API DynamicDiffuseGlobalIlluminationPass : public RendererPass<
{ {
public: public:
// Constant buffer data for DDGI access on a GPU. // Constant buffer data for DDGI access on a GPU.
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ConstantsData GPU_CB_STRUCT(ConstantsData {
{
Float4 ProbesOriginAndSpacing[4]; Float4 ProbesOriginAndSpacing[4];
Int4 ProbesScrollOffsets[4]; Int4 ProbesScrollOffsets[4];
uint32 ProbesCounts[3]; uint32 ProbesCounts[3];

View File

@@ -42,8 +42,7 @@
#include "Engine/Debug/DebugDraw.h" #include "Engine/Debug/DebugDraw.h"
#endif #endif
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data0 GPU_CB_STRUCT(Data0 {
{
Float3 ViewWorldPos; Float3 ViewWorldPos;
float ViewNearPlane; float ViewNearPlane;
float SkyboxIntensity; float SkyboxIntensity;

View File

@@ -11,8 +11,7 @@ class FLAXENGINE_API GlobalSurfaceAtlasPass : public RendererPass<GlobalSurfaceA
{ {
public: public:
// Constant buffer data for Global Surface Atlas access on a GPU. // Constant buffer data for Global Surface Atlas access on a GPU.
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ConstantsData GPU_CB_STRUCT(ConstantsData {
{
Float3 ViewPos; Float3 ViewPos;
float Padding0; float Padding0;
float Padding1; float Padding1;

View File

@@ -39,8 +39,7 @@ static_assert(GLOBAL_SDF_RASTERIZE_MODEL_MAX_COUNT % 4 == 0, "Must be multiple o
#include "Engine/Debug/DebugDraw.h" #include "Engine/Debug/DebugDraw.h"
#endif #endif
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ObjectRasterizeData GPU_CB_STRUCT(ObjectRasterizeData {
{
Matrix3x4 WorldToVolume; Matrix3x4 WorldToVolume;
Matrix3x4 VolumeToWorld; Matrix3x4 VolumeToWorld;
Float3 VolumeToUVWMul; Float3 VolumeToUVWMul;
@@ -51,8 +50,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ObjectRasterizeData
float DecodeAdd; float DecodeAdd;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Float3 ViewWorldPos; Float3 ViewWorldPos;
float ViewNearPlane; float ViewNearPlane;
Float3 Padding00; Float3 Padding00;
@@ -61,8 +59,7 @@ PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data
GlobalSignDistanceFieldPass::ConstantsData GlobalSDF; GlobalSignDistanceFieldPass::ConstantsData GlobalSDF;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ModelsRasterizeData GPU_CB_STRUCT(ModelsRasterizeData {
{
Int3 ChunkCoord; Int3 ChunkCoord;
float MaxDistance; float MaxDistance;
Float3 CascadeCoordToPosMul; Float3 CascadeCoordToPosMul;

View File

@@ -12,8 +12,7 @@ class FLAXENGINE_API GlobalSignDistanceFieldPass : public RendererPass<GlobalSig
{ {
public: public:
// Constant buffer data for Global SDF access on a GPU. // Constant buffer data for Global SDF access on a GPU.
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ConstantsData GPU_CB_STRUCT(ConstantsData {
{
Float4 CascadePosDistance[4]; Float4 CascadePosDistance[4];
Float4 CascadeVoxelSize; Float4 CascadeVoxelSize;
Float2 Padding; Float2 Padding;

View File

@@ -16,7 +16,7 @@
#define THREADGROUP_SIZE_Y 16 #define THREADGROUP_SIZE_Y 16
#define HISTOGRAM_SIZE 64 #define HISTOGRAM_SIZE 64
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) HistogramData { GPU_CB_STRUCT(HistogramData {
uint32 InputSizeX; uint32 InputSizeX;
uint32 InputSizeY; uint32 InputSizeY;
float HistogramMul; float HistogramMul;

View File

@@ -13,12 +13,12 @@
#include "Engine/Content/Assets/CubeTexture.h" #include "Engine/Content/Assets/CubeTexture.h"
#include "Engine/Content/Content.h" #include "Engine/Content/Content.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) PerLight{ GPU_CB_STRUCT(PerLight {
ShaderLightData Light; ShaderLightData Light;
Matrix WVP; Matrix WVP;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) PerFrame{ GPU_CB_STRUCT(PerFrame {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
}); });

View File

@@ -17,7 +17,7 @@
#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUShader.h"
#include "Engine/Engine/Time.h" #include "Engine/Engine/Time.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
Matrix CurrentVP; Matrix CurrentVP;
Matrix PreviousVP; Matrix PreviousVP;

View File

@@ -15,7 +15,7 @@ class PostProcessingPass : public RendererPass<PostProcessingPass>
{ {
private: private:
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
float BloomLimit; float BloomLimit;
float BloomThreshold; float BloomThreshold;
float BloomMagnitude; float BloomMagnitude;
@@ -56,7 +56,7 @@ private:
Matrix LensFlareStarMat; Matrix LensFlareStarMat;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) GaussianBlurData { GPU_CB_STRUCT(GaussianBlurData {
Float2 Size; Float2 Size;
float Dummy3; float Dummy3;
float Dummy4; float Dummy4;

View File

@@ -69,8 +69,7 @@ public:
} }
}; };
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Float2 Dummy0; Float2 Dummy0;
int32 CubeFace; int32 CubeFace;
float SourceMipIndex; float SourceMipIndex;

View File

@@ -13,7 +13,7 @@
#include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderTargetPool.h"
#include "Engine/Level/Actors/EnvironmentProbe.h" #include "Engine/Level/Actors/EnvironmentProbe.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
ShaderEnvProbeData PData; ShaderEnvProbeData PData;
Matrix WVP; Matrix WVP;
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;

View File

@@ -17,15 +17,12 @@
#include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/GPUContext.h"
#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTask.h"
#define RESOLVE_PASS_OUTPUT_FORMAT PixelFormat::R16G16B16A16_Float
// Shader input texture slots mapping // Shader input texture slots mapping
#define TEXTURE0 4 #define TEXTURE0 4
#define TEXTURE1 5 #define TEXTURE1 5
#define TEXTURE2 6 #define TEXTURE2 6
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
float MaxColorMiplevel; float MaxColorMiplevel;
@@ -197,7 +194,7 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
tempDesc = GPUTextureDescription::New2D(traceWidth, traceHeight, PixelFormat::R16G16B16A16_Float); tempDesc = GPUTextureDescription::New2D(traceWidth, traceHeight, PixelFormat::R16G16B16A16_Float);
auto traceBuffer = RenderTargetPool::Get(tempDesc); auto traceBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(traceBuffer, "SSR.TraceBuffer"); RENDER_TARGET_POOL_SET_NAME(traceBuffer, "SSR.TraceBuffer");
tempDesc = GPUTextureDescription::New2D(resolveWidth, resolveHeight, RESOLVE_PASS_OUTPUT_FORMAT); tempDesc = GPUTextureDescription::New2D(resolveWidth, resolveHeight, PixelFormat::R16G16B16A16_Float);
auto resolveBuffer = RenderTargetPool::Get(tempDesc); auto resolveBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(resolveBuffer, "SSR.ResolveBuffer"); RENDER_TARGET_POOL_SET_NAME(resolveBuffer, "SSR.ResolveBuffer");
@@ -253,7 +250,7 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
// Wrong size temporal buffer // Wrong size temporal buffer
if (buffers->TemporalSSR) if (buffers->TemporalSSR)
RenderTargetPool::Release(buffers->TemporalSSR); RenderTargetPool::Release(buffers->TemporalSSR);
tempDesc = GPUTextureDescription::New2D(temporalWidth, temporalHeight, RESOLVE_PASS_OUTPUT_FORMAT); tempDesc = GPUTextureDescription::New2D(temporalWidth, temporalHeight, PixelFormat::R16G16B16A16_Float);
buffers->TemporalSSR = RenderTargetPool::Get(tempDesc); buffers->TemporalSSR = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(buffers->TemporalSSR, "SSR.TemporalSSR"); RENDER_TARGET_POOL_SET_NAME(buffers->TemporalSSR, "SSR.TemporalSSR");
} }
@@ -378,7 +375,7 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
GPUTexture* reflectionsBuffer = resolveBuffer; GPUTexture* reflectionsBuffer = resolveBuffer;
if (useTemporal) if (useTemporal)
{ {
tempDesc = GPUTextureDescription::New2D(temporalWidth, temporalHeight, RESOLVE_PASS_OUTPUT_FORMAT); tempDesc = GPUTextureDescription::New2D(temporalWidth, temporalHeight, PixelFormat::R16G16B16A16_Float);
auto newTemporal = RenderTargetPool::Get(tempDesc); auto newTemporal = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(newTemporal, "SSR.TemporalSSR"); RENDER_TARGET_POOL_SET_NAME(newTemporal, "SSR.TemporalSSR");
const auto oldTemporal = buffers->TemporalSSR; const auto oldTemporal = buffers->TemporalSSR;

View File

@@ -28,7 +28,7 @@
#define NormalOffsetScaleTweak METERS_TO_UNITS(1) #define NormalOffsetScaleTweak METERS_TO_UNITS(1)
#define LocalLightNearPlane METERS_TO_UNITS(0.1f) #define LocalLightNearPlane METERS_TO_UNITS(0.1f)
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data{ GPU_CB_STRUCT(Data {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
ShaderLightData Light; ShaderLightData Light;
Matrix WVP; Matrix WVP;

View File

@@ -15,7 +15,7 @@ struct Item
uint32 Value; uint32 Value;
}; };
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Item NullItem; Item NullItem;
uint32 CounterOffset; uint32 CounterOffset;
uint32 MaxIterations; uint32 MaxIterations;

View File

@@ -5,7 +5,7 @@
#include "Engine/Content/Content.h" #include "Engine/Content/Content.h"
#include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/GPUContext.h"
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
Float2 TexelSize; Float2 TexelSize;
Float2 Padding; Float2 Padding;
}); });

View File

@@ -28,14 +28,14 @@ public:
private: private:
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) SkyLightData { GPU_CB_STRUCT(SkyLightData {
Float3 MultiplyColor; Float3 MultiplyColor;
float VolumetricScatteringIntensity; float VolumetricScatteringIntensity;
Float3 AdditiveColor; Float3 AdditiveColor;
float Dummy0; float Dummy0;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data { GPU_CB_STRUCT(Data {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
Float3 GlobalAlbedo; Float3 GlobalAlbedo;
@@ -67,7 +67,7 @@ private:
DynamicDiffuseGlobalIlluminationPass::ConstantsData DDGI; DynamicDiffuseGlobalIlluminationPass::ConstantsData DDGI;
}); });
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) PerLight { GPU_CB_STRUCT(PerLight {
Float2 SliceToDepth; Float2 SliceToDepth;
int32 MinZ; int32 MinZ;
float LocalLightScatteringIntensity; float LocalLightScatteringIntensity;

View File

@@ -23,7 +23,7 @@
namespace ShadowsOfMordor namespace ShadowsOfMordor
{ {
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderData { GPU_CB_STRUCT(ShaderData {
Rectangle LightmapArea; Rectangle LightmapArea;
Matrix WorldMatrix; Matrix WorldMatrix;
Matrix ToTangentSpace; Matrix ToTangentSpace;

View File

@@ -90,8 +90,7 @@ class GPUModelSDFTask : public GPUTask
Float3 _xyzToLocalMul, _xyzToLocalAdd; Float3 _xyzToLocalMul, _xyzToLocalAdd;
const uint32 ThreadGroupSize = 64; const uint32 ThreadGroupSize = 64;
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) Data GPU_CB_STRUCT(Data {
{
Int3 Resolution; Int3 Resolution;
uint32 ResolutionSize; uint32 ResolutionSize;
float MaxDistance; float MaxDistance;