Add constant buffers alignment for data structures (16-byte boundaries)

This commit is contained in:
Wojtek Figat
2024-05-23 13:58:46 +02:00
parent 91aa5a0fb9
commit 206ff89587
38 changed files with 54 additions and 49 deletions

View File

@@ -6,11 +6,12 @@
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Math/Vector4.h"
#include "Engine/Graphics/Config.h"
/// <summary>
/// Structure that contains information about GBuffer for shaders.
/// </summary>
PACK_STRUCT(struct ShaderGBufferData
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderGBufferData
{
Float4 ViewInfo;
Float4 ScreenSize;
@@ -23,7 +24,7 @@ PACK_STRUCT(struct ShaderGBufferData
/// <summary>
/// Structure that contains information about exponential height fog for shaders.
/// </summary>
PACK_STRUCT(struct ShaderExponentialHeightFogData
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderExponentialHeightFogData
{
Float3 FogInscatteringColor;
float FogMinOpacity;
@@ -48,7 +49,7 @@ PACK_STRUCT(struct ShaderExponentialHeightFogData
/// <summary>
/// Structure that contains information about atmosphere fog for shaders.
/// </summary>
PACK_STRUCT(struct ShaderAtmosphericFogData
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderAtmosphericFogData
{
float AtmosphericFogDensityScale;
float AtmosphericFogSunDiscScale;
@@ -70,7 +71,7 @@ PACK_STRUCT(struct ShaderAtmosphericFogData
/// <summary>
/// Structure that contains information about light for shaders.
/// </summary>
PACK_STRUCT(struct ShaderLightData {
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderLightData {
Float2 SpotAngles;
float SourceRadius;
float SourceLength;
@@ -89,7 +90,7 @@ PACK_STRUCT(struct ShaderLightData {
/// <summary>
/// Packed env probe data
/// </summary>
PACK_STRUCT(struct ShaderEnvProbeData {
PACK_STRUCT(struct alignas(GPU_SHADER_DATA_ALIGNMENT) ShaderEnvProbeData {
Float4 Data0; // x - Position.x, y - Position.y, z - Position.z, w - unused
Float4 Data1; // x - Radius , y - 1 / Radius, z - Brightness, w - unused
});