Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

cbuffer PerFrame : register(b0)
{
float LightsNear;
float LightsFar;
uint2 pad0;
uint4 ClusterSize;
float LightsNear;
float LightsFar;
uint2 pad0; // Padding for 16-byte alignment: 8 -> 16 bytes
uint4 ClusterSize;
}

float3 GetPositionVS(float2 texcoord, float depth, int eyeIndex = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

cbuffer PerFrame : register(b0)
{
uint LightCount;
uint3 pad;
uint4 ClusterSize;
uint LightCount;
uint3 pad0; // Padding for 16-byte alignment: 4 -> 16 bytes
uint4 ClusterSize;
}

//references
Expand Down
3 changes: 3 additions & 0 deletions src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <wrl\client.h>
#include <wrl\wrappers\corewrappers.h>

#define STATIC_ASSERT_ALIGNAS_16(structName) \
static_assert(sizeof(structName) % 16 == 0, #structName " is not a multiple of 16.");

template <typename T>
D3D11_BUFFER_DESC StructuredBufferDesc(uint64_t count, bool uav = true, bool dynamic = false)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Deferred.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

#define ALBEDO RE::RENDER_TARGETS::kINDIRECT
#define SPECULAR RE::RENDER_TARGETS::kINDIRECT_DOWNSCALED
#define REFLECTANCE RE::RENDER_TARGETS::kRAWINDIRECT
Expand Down Expand Up @@ -62,6 +64,7 @@ class Deferred
DirectX::XMFLOAT4X3 ShadowMapProj[2][3];
DirectX::XMFLOAT4X3 CameraViewProjInverse[2];
};
STATIC_ASSERT_ALIGNAS_16(PerGeometry);

ID3D11ComputeShader* copyShadowCS = nullptr;
Buffer* perShadow = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions src/Features/DynamicCubemaps.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

class MenuOpenCloseEventHandler : public RE::BSTEventSink<RE::MenuOpenCloseEvent>
{
public:
Expand All @@ -21,6 +23,7 @@ struct DynamicCubemaps : Feature
float roughness;
float pad[3];
};
STATIC_ASSERT_ALIGNAS_16(SpecularMapFilterSettingsCB);

ID3D11ComputeShader* specularIrradianceCS = nullptr;
ConstantBuffer* spmapCB = nullptr;
Expand All @@ -36,6 +39,7 @@ struct DynamicCubemaps : Feature
float3 CameraPreviousPosAdjust;
uint pad0;
};
STATIC_ASSERT_ALIGNAS_16(UpdateCubemapCB);

ID3D11ComputeShader* updateCubemapCS = nullptr;
ID3D11ComputeShader* updateCubemapReflectionsCS = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions src/Features/ExtendedMaterials.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct ExtendedMaterials : Feature
{
virtual inline std::string GetName() override { return "Extended Materials"; }
Expand Down Expand Up @@ -36,6 +38,7 @@ struct ExtendedMaterials : Feature

float pad[1];
};
STATIC_ASSERT_ALIGNAS_16(Settings);

Settings settings;

Expand Down
4 changes: 4 additions & 0 deletions src/Features/GrassCollision.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct GrassCollision : Feature
{
private:
Expand Down Expand Up @@ -43,6 +45,7 @@ struct GrassCollision : Feature
uint IndexEnd = 0;
float2 pad0;
};
STATIC_ASSERT_ALIGNAS_16(BoundingBoxPacked);

struct alignas(16) PerFrame
{
Expand All @@ -56,6 +59,7 @@ struct GrassCollision : Feature
float CameraHeightDelta;
float3 pad0;
};
STATIC_ASSERT_ALIGNAS_16(PerFrame);

Settings settings;

Expand Down
3 changes: 3 additions & 0 deletions src/Features/GrassLighting.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct GrassLighting : Feature
{
private:
Expand Down Expand Up @@ -35,6 +37,7 @@ struct GrassLighting : Feature
float BasicGrassBrightness = 1.0f;
uint pad[3];
};
STATIC_ASSERT_ALIGNAS_16(Settings);

Settings settings;

Expand Down
8 changes: 8 additions & 0 deletions src/Features/LightLimitFix.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct LightLimitFix : Feature
{
private:
Expand Down Expand Up @@ -59,6 +61,7 @@ struct LightLimitFix : Feature
uint pad0;
uint pad1;
};
STATIC_ASSERT_ALIGNAS_16(LightData);

struct ClusterAABB
{
Expand All @@ -72,6 +75,7 @@ struct LightLimitFix : Feature
uint lightCount;
uint pad0[2];
};
STATIC_ASSERT_ALIGNAS_16(LightGrid);

struct alignas(16) LightBuildingCB
{
Expand All @@ -80,13 +84,15 @@ struct LightLimitFix : Feature
uint pad0[2];
uint ClusterSize[4];
};
STATIC_ASSERT_ALIGNAS_16(LightBuildingCB);

struct alignas(16) LightCullingCB
{
uint LightCount;
uint pad[3];
uint ClusterSize[4];
};
STATIC_ASSERT_ALIGNAS_16(LightCullingCB);

struct alignas(16) PerFrame
{
Expand All @@ -95,6 +101,7 @@ struct LightLimitFix : Feature
float pad0[2];
uint ClusterSize[4];
};
STATIC_ASSERT_ALIGNAS_16(PerFrame);

PerFrame GetCommonBufferData();

Expand All @@ -106,6 +113,7 @@ struct LightLimitFix : Feature
uint pad0;
LightData StrictLights[15];
};
STATIC_ASSERT_ALIGNAS_16(StrictLightDataCB);

StrictLightDataCB strictLightDataTemp;

Expand Down
3 changes: 3 additions & 0 deletions src/Features/ScreenSpaceGI.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct ScreenSpaceGI : Feature
{
private:
Expand Down Expand Up @@ -126,6 +128,7 @@ struct ScreenSpaceGI : Feature

float2 pad;
};
STATIC_ASSERT_ALIGNAS_16(SSGICB);
eastl::unique_ptr<ConstantBuffer> ssgiCB;

eastl::unique_ptr<Texture2D> texNoise = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions src/Features/ScreenSpaceShadows.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct ScreenSpaceShadows : Feature
{
private:
Expand Down Expand Up @@ -62,6 +64,7 @@ struct ScreenSpaceShadows : Feature

BendSettings settings;
};
STATIC_ASSERT_ALIGNAS_16(RaymarchCB);

ID3D11SamplerState* pointBorderSampler = nullptr;

Expand Down
4 changes: 4 additions & 0 deletions src/Features/SubsurfaceScattering.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

#define SSSS_N_SAMPLES 21

struct SubsurfaceScattering : Feature
Expand Down Expand Up @@ -36,6 +38,7 @@ struct SubsurfaceScattering : Feature
{
float4 Sample[SSSS_N_SAMPLES];
};
STATIC_ASSERT_ALIGNAS_16(Kernel);

struct alignas(16) BlurCB
{
Expand All @@ -49,6 +52,7 @@ struct SubsurfaceScattering : Feature
float4 MeanFreePathBase;
float4 MeanFreePathHuman;
};
STATIC_ASSERT_ALIGNAS_16(BlurCB);

ConstantBuffer* blurCB = nullptr;
BlurCB blurCBData{};
Expand Down
2 changes: 2 additions & 0 deletions src/Features/TerrainShadows.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Buffer.h"
#include <filesystem>

struct TerrainShadows : public Feature
Expand Down Expand Up @@ -65,6 +66,7 @@ struct TerrainShadows : public Feature
float2 ZRange;
float2 Offset;
};
STATIC_ASSERT_ALIGNAS_16(PerFrame);

PerFrame GetCommonBufferData();

Expand Down
3 changes: 3 additions & 0 deletions src/Features/WetnessEffects.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "Buffer.h"

struct WetnessEffects : Feature
{
private:
Expand Down Expand Up @@ -69,6 +71,7 @@ struct WetnessEffects : Feature
Settings settings;
uint pad0;
};
STATIC_ASSERT_ALIGNAS_16(PerFrame);

struct DebugSettings
{
Expand Down
2 changes: 2 additions & 0 deletions src/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class State
ExtraFeatureDescriptor == other.ExtraFeatureDescriptor;
}
};
STATIC_ASSERT_ALIGNAS_16(PermutationCB);

ConstantBuffer* permutationCB = nullptr;

Expand All @@ -204,6 +205,7 @@ class State
float MipBias;
float pad0;
};
STATIC_ASSERT_ALIGNAS_16(SharedDataCB);

ConstantBuffer* sharedDataCB = nullptr;
ConstantBuffer* featureDataCB = nullptr;
Expand Down
Loading