Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: shader bindings #808

Merged
merged 2 commits into from
Dec 2, 2024
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
@@ -1,5 +1,5 @@

TextureCube<float4> cloudShadowsTexture : register(t27);
TextureCube<float4> cloudShadowsTexture : register(t25);

#define CloudHeight (2e3f / 1.428e-2)
#define PlanetRadius (6371e3f / 1.428e-2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TextureCube<float4> specularTexture : register(t64);
TextureCube<float4> specularTextureNoReflections : register(t65);
TextureCube<float4> specularTexture : register(t30);
TextureCube<float4> specularTextureNoReflections : register(t31);

namespace DynamicCubemaps
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ struct StrictLightData
uint pad0[2];
};

StructuredBuffer<StructuredLight> lights : register(t50);
StructuredBuffer<uint> lightList : register(t51); //MAX_CLUSTER_LIGHTS * 16^3
StructuredBuffer<LightGrid> lightGrid : register(t52); //16^3
StructuredBuffer<StrictLightData> strictLights : register(t53);
StructuredBuffer<StructuredLight> lights : register(t35);
StructuredBuffer<uint> lightList : register(t36); //MAX_CLUSTER_LIGHTS * 16^3
StructuredBuffer<LightGrid> lightGrid : register(t37); //16^3
StructuredBuffer<StrictLightData> strictLights : register(t38);

namespace LightLimitFix
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Common/Math.hlsli"

Texture2D<unorm half> ScreenSpaceShadowsTexture : register(t17);
Texture2D<unorm half> ScreenSpaceShadowsTexture : register(t45);

namespace ScreenSpaceShadows
{
Expand Down
2 changes: 1 addition & 1 deletion features/Skylighting/Shaders/Skylighting/Skylighting.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Common/Spherical Harmonics/SphericalHarmonics.hlsli"

#ifdef PSHADER
Texture3D<sh2> SkylightingProbeArray : register(t29);
Texture3D<sh2> SkylightingProbeArray : register(t50);
#endif

namespace Skylighting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Texture2D<float4> TerrainBlendingMaskTexture : register(t35);
Texture2D<float4> TerrainBlendingMaskTexture : register(t55);

namespace TerrainBlending
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Texture2D<float2> TexShadowHeight : register(t42);
Texture2D<float2> TexShadowHeight : register(t60);

namespace TerrainShadows
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Texture2D<float4> WaterCaustics : register(t70);
Texture2D<float4> WaterCaustics : register(t65);

namespace WaterEffects
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace WetnessEffects
{
Texture2D<float4> TexPrecipOcclusion : register(t31);
Texture2D<float4> TexPrecipOcclusion : register(t70);

// https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile
float2 EnvBRDFApproxWater(float3 F0, float Roughness, float NoV)
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Common/Glints/Glints2023.hlsli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Common/Math.hlsli"

Texture2D<float4> _Glint2023NoiseMap : register(t28);
Texture2D<float4> _Glint2023NoiseMap : register(t20);

namespace Glints
{
Expand Down
4 changes: 2 additions & 2 deletions package/Shaders/Common/ShadowSampling.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Common/Random.hlsli"
#include "Common/SharedData.hlsli"

Texture2DArray<float4> SharedTexShadowMapSampler : register(t25);
Texture2DArray<float4> SharedTexShadowMapSampler : register(t18);

struct PerGeometry
{
Expand All @@ -24,7 +24,7 @@ struct PerGeometry
float4x4 CameraViewProjInverse[2];
};

StructuredBuffer<PerGeometry> SharedPerShadow : register(t26);
StructuredBuffer<PerGeometry> SharedPerShadow : register(t19);

namespace ShadowSampling
{
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Common/SharedData.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ cbuffer FeatureData : register(b6)
SkylightingSettings skylightingSettings;
};

Texture2D<float4> TexDepthSampler : register(t20);
Texture2D<float4> TexDepthSampler : register(t17);

namespace SharedData
{
Expand Down
2 changes: 1 addition & 1 deletion src/Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void Deferred::CopyShadowData()
perShadow->srv.get(),
};

context->PSSetShaderResources(25, ARRAYSIZE(srvs), srvs);
context->PSSetShaderResources(18, ARRAYSIZE(srvs), srvs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Features/CloudShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void CloudShadows::Prepass()
auto& context = State::GetSingleton()->context;

ID3D11ShaderResourceView* srv = texCubemapCloudOcc->srv.get();
context->PSSetShaderResources(27, 1, &srv);
context->PSSetShaderResources(25, 1, &srv);
}

void CloudShadows::SetupResources()
Expand Down
2 changes: 1 addition & 1 deletion src/Features/DynamicCubemaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void DynamicCubemaps::PostDeferred()
auto& context = State::GetSingleton()->context;

ID3D11ShaderResourceView* views[2] = { (activeReflections ? envReflectionsTexture : envTexture)->srv.get(), envTexture->srv.get() };
context->PSSetShaderResources(64, 2, views);
context->PSSetShaderResources(30, 2, views);
}

void DynamicCubemaps::SetupResources()
Expand Down
4 changes: 2 additions & 2 deletions src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void LightLimitFix::BSLightingShader_SetupGeometry_After(RE::BSRenderPass*)
static Util::FrameChecker frameChecker;
if (frameChecker.IsNewFrame()) {
ID3D11ShaderResourceView* view = strictLightData->srv.get();
context->PSSetShaderResources(53, 1, &view);
context->PSSetShaderResources(38, 1, &view);
}
}

Expand Down Expand Up @@ -458,7 +458,7 @@ void LightLimitFix::Prepass()
views[0] = lights->srv.get();
views[1] = lightIndexList->srv.get();
views[2] = lightGrid->srv.get();
context->PSSetShaderResources(50, ARRAYSIZE(views), views);
context->PSSetShaderResources(35, ARRAYSIZE(views), views);
}

bool LightLimitFix::IsValidLight(RE::BSLight* a_light)
Expand Down
2 changes: 1 addition & 1 deletion src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void ScreenSpaceShadows::Prepass()
DrawShadows();

auto view = screenSpaceShadowsTexture->srv.get();
context->PSSetShaderResources(17, 1, &view);
context->PSSetShaderResources(45, 1, &view);
}

void ScreenSpaceShadows::LoadSettings(json& o_json)
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Skylighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void Skylighting::Prepass()
// set PS shader resource
{
ID3D11ShaderResourceView* srv = texProbeArray->srv.get();
context->PSSetShaderResources(29, 1, &srv);
context->PSSetShaderResources(50, 1, &srv);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Features/TerrainBlending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void TerrainBlending::OverrideTerrainWorld()

// Used to get the distance of the surface to the lowest depth
auto view = terrainOffsetTexture->srv.get();
context->PSSetShaderResources(35, 1, &view);
context->PSSetShaderResources(55, 1, &view);
}

void TerrainBlending::OverrideTerrainDepth()
Expand Down
2 changes: 1 addition & 1 deletion src/Features/TerrainShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,6 @@ void TerrainShadows::Prepass()
std::array<ID3D11ShaderResourceView*, 3> srvs = { nullptr };
if (texShadowHeight)
srvs.at(2) = texShadowHeight->srv.get();
context->PSSetShaderResources(40, (uint)srvs.size(), srvs.data());
context->PSSetShaderResources(60, (uint)srvs.size(), srvs.data());
}
}
2 changes: 1 addition & 1 deletion src/Features/WaterEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void WaterEffects::Prepass()
{
auto& context = State::GetSingleton()->context;
auto srv = causticsView.get();
context->PSSetShaderResources(70, 1, &srv);
context->PSSetShaderResources(65, 1, &srv);
}

bool WaterEffects::HasShaderDefine(RE::BSShader::Type)
Expand Down
2 changes: 1 addition & 1 deletion src/Features/WetnessEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void WetnessEffects::Prepass()
auto state = State::GetSingleton();
auto& context = state->context;

context->PSSetShaderResources(31, 1, &precipOcclusionTexture.depthSRV);
context->PSSetShaderResources(70, 1, &precipOcclusionTexture.depthSRV);
}

void WetnessEffects::LoadSettings(json& o_json)
Expand Down
2 changes: 1 addition & 1 deletion src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ void State::UpdateSharedData()
auto terrainBlending = TerrainBlending::GetSingleton();
auto srv = (terrainBlending->loaded ? terrainBlending->blendedDepthTexture16->srv.get() : depth.depthSRV);

context->PSSetShaderResources(20, 1, &srv);
context->PSSetShaderResources(17, 1, &srv);
}

void State::ClearDisabledFeatures()
Expand Down
2 changes: 1 addition & 1 deletion src/TruePBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void TruePBR::PrePass()
if (!glintsNoiseTexture)
SetupGlintsTexture();
ID3D11ShaderResourceView* srv = glintsNoiseTexture->srv.get();
context->PSSetShaderResources(28, 1, &srv);
context->PSSetShaderResources(20, 1, &srv);
}

void TruePBR::SetupGlintsTexture()
Expand Down
Loading