mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-17 19:23:51 +02:00
Added screensapce decal system and stamp placement system in Radiant.
This commit is contained in:
@@ -2461,6 +2461,7 @@ struct glRaytracingLightingConstants_t
|
||||
float denoisePhiNormal;
|
||||
float denoisePhiPosition;
|
||||
float bumpStrength;
|
||||
|
||||
};
|
||||
|
||||
struct glRaytracingMeshMetadata_t
|
||||
@@ -2560,7 +2561,6 @@ struct glRaytracingLightingState_t
|
||||
static glRaytracingLightingState_t g_glRaytracingLighting;
|
||||
|
||||
static const DXGI_FORMAT GL_RAYTRACING_DENOISE_FORMAT = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
enum glRaytracingLightingDescriptorIndex_t
|
||||
{
|
||||
GLR_DESC_LIGHTS_SRV = 0,
|
||||
@@ -3101,6 +3101,8 @@ float3 Doom3SafeNormalizeOr(float3 v, float3 fallbackDir)
|
||||
return (lenSq > 1e-8) ? (v * rsqrt(lenSq)) : fallbackDir;
|
||||
}
|
||||
|
||||
)"
|
||||
R"(
|
||||
float Doom3QuadraticFalloffImage(float texCoord)
|
||||
{
|
||||
// Math version of Doom 3 BFG's built-in _quadratic lookup table.
|
||||
@@ -3122,7 +3124,8 @@ float Doom3QuadraticFalloffImage(float texCoord)
|
||||
d = saturate(d);
|
||||
return d * d;
|
||||
}
|
||||
|
||||
)"
|
||||
R"(
|
||||
float Doom3QuadraticCentered(float centeredCoord)
|
||||
{
|
||||
// centeredCoord is -1 at one side of the light volume, 0 at the light center,
|
||||
@@ -7220,7 +7223,6 @@ void glRaytracingLightingSetShadowBias(float bias)
|
||||
glRaytracingLightingUpdateConstants();
|
||||
}
|
||||
|
||||
|
||||
void glRaytracingLightingSetPathTracingOptions(uint32_t samplesPerPixel, uint32_t maxBounces, int enableDenoiser, float denoiseStrength)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_glRaytracingMutex);
|
||||
|
||||
@@ -466,10 +466,11 @@ static const UINT QD3D12_UploadBufferSize = 128 * 1024 * 1024;
|
||||
// MSAA has been removed from the G-buffer path. Temporal AA now owns edge cleanup
|
||||
// after lighting, so all scene/deferred render targets remain single-sample.
|
||||
static const UINT QD3D12_RequestedGBufferSampleCount = 1;
|
||||
static constexpr UINT QD3D12_PostSrvCount = 11;
|
||||
static constexpr UINT QD3D12_PostSrvCount = 14;
|
||||
static constexpr UINT QD3D12_PostRootConstants = QD3D12_PostSrvCount;
|
||||
static constexpr UINT QD3D12_PostConstantDwords = 24;
|
||||
static constexpr UINT QD3D12_ToneMapTileDim = 64;
|
||||
static constexpr UINT QD3D12_MaxScreenSpaceDecals = 64;
|
||||
|
||||
enum QD3D12RTVSlotGroup
|
||||
{
|
||||
@@ -1517,6 +1518,13 @@ struct GLState
|
||||
uint32_t pathTracingSamplesPerPixel = 1;
|
||||
uint32_t pathTracingFallbackSamplesPerPixel = 2;
|
||||
uint32_t pathTracingMaxBounces = 2;
|
||||
glScreenSpaceDecal_t screenSpaceDecals[QD3D12_MaxScreenSpaceDecals] = {};
|
||||
uint32_t screenSpaceDecalCount = 0;
|
||||
ComPtr<ID3D12Resource> screenSpaceDecalBuffer;
|
||||
void* screenSpaceDecalBufferMapped = nullptr;
|
||||
UINT screenSpaceDecalSrvIndex = UINT_MAX;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE screenSpaceDecalSrvCpu{};
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE screenSpaceDecalSrvGpu{};
|
||||
|
||||
float jitterX = 0.0f;
|
||||
float jitterY = 0.0f;
|
||||
@@ -1696,6 +1704,7 @@ struct GLState
|
||||
ComPtr<ID3D12PipelineState> postDepthCopyPSO;
|
||||
ComPtr<ID3D12PipelineState> postDepthResolveMsaaPSO;
|
||||
ComPtr<ID3D12PipelineState> postGBufferPointResolveMsaaPSO;
|
||||
ComPtr<ID3D12PipelineState> postScreenDecalPSO;
|
||||
|
||||
ComPtr<ID3DBlob> vsMainBlob;
|
||||
ComPtr<ID3DBlob> hsMainBlob;
|
||||
@@ -1717,6 +1726,7 @@ struct GLState
|
||||
ComPtr<ID3DBlob> postPsDepthCopyBlob;
|
||||
ComPtr<ID3DBlob> postPsDepthResolveMsaaBlob;
|
||||
ComPtr<ID3DBlob> postPsGBufferPointResolveMsaaBlob;
|
||||
ComPtr<ID3DBlob> postPsScreenDecalBlob;
|
||||
|
||||
TextureResource whiteTexture;
|
||||
|
||||
@@ -4381,8 +4391,27 @@ Texture2D gTaaHistory : register(t7);
|
||||
Texture2D gTaaVelocity : register(t8);
|
||||
Texture2D<float4> gFogPosition : register(t9);
|
||||
Texture2D<float> gFogDepth : register(t10);
|
||||
Texture2D<float4> gScreenDecalNormal : register(t11);
|
||||
Texture2D<float4> gScreenDecalPosition : register(t12);
|
||||
SamplerState gSamp0 : register(s0);
|
||||
|
||||
struct ScreenSpaceDecal
|
||||
{
|
||||
float3 origin;
|
||||
float halfSize;
|
||||
float3 normal;
|
||||
float depth;
|
||||
float3 axisU;
|
||||
float opacity;
|
||||
float3 axisV;
|
||||
float pad0;
|
||||
float4 color;
|
||||
uint textureId;
|
||||
float3 pad1;
|
||||
};
|
||||
|
||||
StructuredBuffer<ScreenSpaceDecal> gScreenDecals : register(t13);
|
||||
|
||||
cbuffer PostCB : register(b0)
|
||||
{
|
||||
// gPostParams0: x = sharpen strength, y = history weight, z = TAA reset flag.
|
||||
@@ -4400,6 +4429,7 @@ cbuffer PostCB : register(b0)
|
||||
#define gPostSharpness gPostParams0.x
|
||||
#define gTaaHistoryWeight gPostParams0.y
|
||||
#define gTaaReset gPostParams0.z
|
||||
#define gScreenDecalIndex gPostParams0.w
|
||||
#define gToneMapExposure gPostParams1.x
|
||||
#define gToneMapWhiteScale gPostParams1.y
|
||||
#define gToneMapBrightness gPostParams1.z
|
||||
@@ -4409,6 +4439,7 @@ cbuffer PostCB : register(b0)
|
||||
#define gPostFogStart gPostParams2.w
|
||||
#define gPostFogEnd gPostParams3.x
|
||||
#define gPostFogCameraValid gPostParams3.y
|
||||
#define gScreenDecalCount gPostFogCameraWorldPos.w
|
||||
#define QD3D12_TONEMAP_TILE_DIM 64u
|
||||
|
||||
struct VSOut
|
||||
@@ -4470,6 +4501,53 @@ float4 QD3D12_ApplyPostFog(float4 color, float2 uv)
|
||||
return color;
|
||||
}
|
||||
|
||||
float3 QD3D12_SafeNormalizeOr(float3 v, float3 fallbackDir)
|
||||
{
|
||||
float lenSq = dot(v, v);
|
||||
return (lenSq > 1e-8) ? (v * rsqrt(lenSq)) : fallbackDir;
|
||||
}
|
||||
|
||||
float4 PSScreenDecals(VSOut i) : SV_Target0
|
||||
{
|
||||
uint2 pixel = uint2(i.pos.xy);
|
||||
float3 worldPos = gScreenDecalPosition.Load(int3(pixel, 0)).xyz;
|
||||
float3 normal = QD3D12_SafeNormalizeOr(gScreenDecalNormal.Load(int3(pixel, 0)).xyz, float3(0.0, 0.0, 1.0));
|
||||
float3 geometricNormal = QD3D12_SafeNormalizeOr(cross(ddx(worldPos), ddy(worldPos)), normal);
|
||||
float3 decalColor = 0.0;
|
||||
float decalAlpha = 0.0;
|
||||
uint decalIndex = (uint)gScreenDecalIndex;
|
||||
if (decalIndex >= min((uint)gScreenDecalCount, 64u))
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
ScreenSpaceDecal d = gScreenDecals[decalIndex];
|
||||
float3 decalN = QD3D12_SafeNormalizeOr(d.normal, normal);
|
||||
float facing = saturate(abs(dot(geometricNormal, decalN)) * 4.0);
|
||||
if (facing <= 0.0)
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
float3 rel = worldPos - d.origin;
|
||||
float decalDepth = max(d.depth, 1.0e-3);
|
||||
float depthDistance = abs(dot(rel, decalN));
|
||||
float depthFade = 1.0 - smoothstep(decalDepth, decalDepth + max(decalDepth * 0.25, 1.0), depthDistance);
|
||||
if (depthFade <= 0.0)
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
float3 axisU = QD3D12_SafeNormalizeOr(d.axisU, float3(1.0, 0.0, 0.0));
|
||||
float3 axisV = QD3D12_SafeNormalizeOr(d.axisV, cross(decalN, axisU));
|
||||
float2 uv = float2(dot(rel, axisU), dot(rel, axisV)) / max(d.halfSize, 1.0e-3);
|
||||
if (abs(uv.x) >= 1.0 || abs(uv.y) >= 1.0)
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
float2 texUv = float2(uv.x * 0.5 + 0.5, -uv.y * 0.5 + 0.5);
|
||||
float4 texel = gTex0.Sample(gSamp0, texUv);
|
||||
float edge = smoothstep(1.0, 0.75, max(abs(uv.x), abs(uv.y)));
|
||||
float mask = saturate(d.opacity) * facing * depthFade * edge * saturate(d.color.a) * saturate(texel.a);
|
||||
decalColor = texel.rgb * saturate(d.color.rgb);
|
||||
decalAlpha = mask;
|
||||
|
||||
return float4(decalColor, decalAlpha);
|
||||
}
|
||||
|
||||
float4 PSCopy(VSOut i) : SV_Target0
|
||||
{
|
||||
return QD3D12_ApplyPostFog(gTex0.Sample(gSamp0, i.uv), i.uv);
|
||||
@@ -4773,7 +4851,8 @@ struct PSGBufferPointResolveOut
|
||||
float4 emissive : SV_Target3;
|
||||
float4 specular : SV_Target4;
|
||||
};
|
||||
|
||||
)HLSL"
|
||||
R"HLSL(
|
||||
PSGBufferPointResolveOut PSGBufferPointResolveMS(VSOut i)
|
||||
{
|
||||
uint srcW, srcH, sampleCount;
|
||||
@@ -7617,7 +7696,9 @@ static void QD3D12_SetPostConstants(
|
||||
float toneMapExposure = 1.0f,
|
||||
float toneMapWhiteScale = 1.0f,
|
||||
float toneMapBrightness = 1.0f,
|
||||
bool applySceneFog = false)
|
||||
bool applySceneFog = false,
|
||||
float screenDecalCount = 0.0f,
|
||||
float screenDecalIndex = 0.0f)
|
||||
{
|
||||
if (!cl)
|
||||
return;
|
||||
@@ -7626,6 +7707,7 @@ static void QD3D12_SetPostConstants(
|
||||
constants[0] = sharpness;
|
||||
constants[1] = taaHistoryWeight;
|
||||
constants[2] = taaReset;
|
||||
constants[3] = screenDecalIndex;
|
||||
constants[4] = toneMapExposure;
|
||||
constants[5] = toneMapWhiteScale;
|
||||
constants[6] = toneMapBrightness;
|
||||
@@ -7645,6 +7727,7 @@ static void QD3D12_SetPostConstants(
|
||||
constants[21] = g_gl.sceneFogCameraWorldPos[1];
|
||||
constants[22] = g_gl.sceneFogCameraWorldPos[2];
|
||||
}
|
||||
constants[23] = screenDecalCount;
|
||||
cl->SetGraphicsRoot32BitConstants(QD3D12_PostRootConstants, QD3D12_PostConstantDwords, constants, 0);
|
||||
}
|
||||
|
||||
@@ -7661,6 +7744,77 @@ static void QD3D12_BindPostFogResources(ID3D12GraphicsCommandList* cl, QD3D12Win
|
||||
cl->SetGraphicsRootDescriptorTable(10, w.depthSrvGpu);
|
||||
}
|
||||
|
||||
static bool QD3D12_EnsureScreenSpaceDecalBuffer()
|
||||
{
|
||||
if (!g_gl.device || !g_gl.srvHeap)
|
||||
return false;
|
||||
|
||||
const UINT64 bufferSize = sizeof(glScreenSpaceDecal_t) * QD3D12_MaxScreenSpaceDecals;
|
||||
if (!g_gl.screenSpaceDecalBuffer)
|
||||
{
|
||||
D3D12_HEAP_PROPERTIES hp{};
|
||||
hp.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||
hp.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
hp.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
hp.CreationNodeMask = 1;
|
||||
hp.VisibleNodeMask = 1;
|
||||
|
||||
D3D12_RESOURCE_DESC rd{};
|
||||
rd.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
rd.Alignment = 0;
|
||||
rd.Width = bufferSize;
|
||||
rd.Height = 1;
|
||||
rd.DepthOrArraySize = 1;
|
||||
rd.MipLevels = 1;
|
||||
rd.Format = DXGI_FORMAT_UNKNOWN;
|
||||
rd.SampleDesc.Count = 1;
|
||||
rd.SampleDesc.Quality = 0;
|
||||
rd.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
rd.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
|
||||
QD3D12_CHECK(g_gl.device->CreateCommittedResource(
|
||||
&hp,
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&rd,
|
||||
D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||
nullptr,
|
||||
IID_PPV_ARGS(&g_gl.screenSpaceDecalBuffer)));
|
||||
|
||||
QD3D12_CHECK(g_gl.screenSpaceDecalBuffer->Map(0, nullptr, &g_gl.screenSpaceDecalBufferMapped));
|
||||
}
|
||||
|
||||
if (g_gl.screenSpaceDecalSrvIndex == UINT_MAX)
|
||||
{
|
||||
g_gl.screenSpaceDecalSrvIndex = g_gl.nextSrvIndex++;
|
||||
g_gl.screenSpaceDecalSrvCpu = QD3D12_SrvCpu(g_gl.screenSpaceDecalSrvIndex);
|
||||
g_gl.screenSpaceDecalSrvGpu = QD3D12_SrvGpu(g_gl.screenSpaceDecalSrvIndex);
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC sd{};
|
||||
sd.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
|
||||
sd.Format = DXGI_FORMAT_UNKNOWN;
|
||||
sd.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
sd.Buffer.FirstElement = 0;
|
||||
sd.Buffer.NumElements = QD3D12_MaxScreenSpaceDecals;
|
||||
sd.Buffer.StructureByteStride = sizeof(glScreenSpaceDecal_t);
|
||||
sd.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE;
|
||||
g_gl.device->CreateShaderResourceView(g_gl.screenSpaceDecalBuffer.Get(), &sd, g_gl.screenSpaceDecalSrvCpu);
|
||||
}
|
||||
|
||||
if (g_gl.screenSpaceDecalBufferMapped)
|
||||
{
|
||||
memset(g_gl.screenSpaceDecalBufferMapped, 0, bufferSize);
|
||||
if (g_gl.screenSpaceDecalCount > 0)
|
||||
{
|
||||
memcpy(
|
||||
g_gl.screenSpaceDecalBufferMapped,
|
||||
g_gl.screenSpaceDecals,
|
||||
sizeof(glScreenSpaceDecal_t) * g_gl.screenSpaceDecalCount);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void QD3D12_PostFullscreenPass(ID3D12GraphicsCommandList* cl,
|
||||
ID3D12PipelineState* pso,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE inputSrv,
|
||||
@@ -7843,6 +7997,91 @@ static void QD3D12_CompositeEmissiveIntoSceneColor(QD3D12Window& w)
|
||||
scissor);
|
||||
}
|
||||
|
||||
void APIENTRY glSetScreenSpaceDecalsQD3D12(const glScreenSpaceDecal_t* decals, uint32_t decalCount)
|
||||
{
|
||||
const uint32_t count = std::min<uint32_t>(decalCount, QD3D12_MaxScreenSpaceDecals);
|
||||
g_gl.screenSpaceDecalCount = count;
|
||||
memset(g_gl.screenSpaceDecals, 0, sizeof(g_gl.screenSpaceDecals));
|
||||
if (decals && count > 0)
|
||||
{
|
||||
memcpy(g_gl.screenSpaceDecals, decals, sizeof(glScreenSpaceDecal_t) * count);
|
||||
}
|
||||
}
|
||||
|
||||
void APIENTRY glDrawScreenSpaceDecalsQD3D12(void)
|
||||
{
|
||||
if (g_gl.screenSpaceDecalCount == 0)
|
||||
return;
|
||||
|
||||
QD3D12Window* window = g_currentWindow;
|
||||
if (!window || !g_gl.device || !g_gl.cmdList || !g_gl.postScreenDecalPSO)
|
||||
return;
|
||||
if (!window->sceneColorBuffers[window->frameIndex] || !window->normalBuffers[window->frameIndex] || !window->positionBuffers[window->frameIndex])
|
||||
return;
|
||||
if (!QD3D12_EnsureScreenSpaceDecalBuffer())
|
||||
return;
|
||||
|
||||
QD3D12_EnsureFrameOpen();
|
||||
QD3D12_FlushQueuedBatches();
|
||||
QD3D12_ResolveGBufferForCurrentFrame(*window);
|
||||
|
||||
const UINT frame = window->frameIndex;
|
||||
ID3D12GraphicsCommandList* cl = g_gl.cmdList.Get();
|
||||
QD3D12_TransitionResource(cl, window->sceneColorBuffers[frame].Get(), window->sceneColorState[frame], D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||
QD3D12_TransitionResource(cl, window->normalBuffers[frame].Get(), window->normalBufferState[frame], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
QD3D12_TransitionResource(cl, window->positionBuffers[frame].Get(), window->positionBufferState[frame], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
D3D12_VIEWPORT viewport{};
|
||||
viewport.TopLeftX = 0.0f;
|
||||
viewport.TopLeftY = 0.0f;
|
||||
viewport.Width = (float)window->renderWidth;
|
||||
viewport.Height = (float)window->renderHeight;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
D3D12_RECT scissor{};
|
||||
scissor.left = 0;
|
||||
scissor.top = 0;
|
||||
scissor.right = (LONG)window->renderWidth;
|
||||
scissor.bottom = (LONG)window->renderHeight;
|
||||
|
||||
ID3D12DescriptorHeap* heaps[] = { g_gl.srvHeap.Get() };
|
||||
cl->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
cl->SetGraphicsRootSignature(g_gl.postRootSig.Get());
|
||||
QD3D12_SetPostConstants(cl, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, false, (float)g_gl.screenSpaceDecalCount);
|
||||
cl->SetPipelineState(g_gl.postScreenDecalPSO.Get());
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE sceneColorRtv = CurrentResolvedSceneColorRTV();
|
||||
cl->OMSetRenderTargets(1, &sceneColorRtv, FALSE, nullptr);
|
||||
cl->RSSetViewports(1, &viewport);
|
||||
cl->RSSetScissorRects(1, &scissor);
|
||||
cl->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
for (uint32_t decalIndex = 0; decalIndex < g_gl.screenSpaceDecalCount; ++decalIndex)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE decalTextureSrv = g_gl.whiteTexture.srvGpu;
|
||||
const glScreenSpaceDecal_t& decal = g_gl.screenSpaceDecals[decalIndex];
|
||||
TextureResource* decalTexture = decal.textureId ? QD3D12_FindTextureResource(decal.textureId) : nullptr;
|
||||
if (decalTexture)
|
||||
{
|
||||
EnsureTextureResource(*decalTexture);
|
||||
if (decalTexture->texture && !decalTexture->gpuValid)
|
||||
{
|
||||
UploadTexture(*decalTexture);
|
||||
}
|
||||
if (decalTexture->texture && decalTexture->srvIndex != UINT_MAX)
|
||||
{
|
||||
decalTextureSrv = decalTexture->srvGpu;
|
||||
}
|
||||
}
|
||||
|
||||
QD3D12_SetPostConstants(cl, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, false, (float)g_gl.screenSpaceDecalCount, (float)decalIndex);
|
||||
cl->SetGraphicsRootDescriptorTable(0, decalTextureSrv);
|
||||
cl->SetGraphicsRootDescriptorTable(11, window->normalSrvGpu[frame]);
|
||||
cl->SetGraphicsRootDescriptorTable(12, window->positionSrvGpu[frame]);
|
||||
cl->SetGraphicsRootDescriptorTable(13, g_gl.screenSpaceDecalSrvGpu);
|
||||
cl->DrawInstanced(3, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static ID3D12Resource* QD3D12_PrepareStreamlineOutputForWrite(QD3D12Window& w)
|
||||
{
|
||||
ID3D12GraphicsCommandList* cl = g_gl.cmdList.Get();
|
||||
@@ -9338,6 +9577,7 @@ static void QD3D12_CompileShaders()
|
||||
g_gl.postPsDepthCopyBlob = CompileShaderSourceVariant(kQD3D12PostHLSL, "PSDepthCopy", "ps_6_0");
|
||||
g_gl.postPsDepthResolveMsaaBlob = CompileShaderSourceVariant(kQD3D12PostHLSL, "PSDepthResolveMS", "ps_6_0");
|
||||
g_gl.postPsGBufferPointResolveMsaaBlob = CompileShaderSourceVariant(kQD3D12PostHLSL, "PSGBufferPointResolveMS", "ps_6_0");
|
||||
g_gl.postPsScreenDecalBlob = CompileShaderSourceVariant(kQD3D12PostHLSL, "PSScreenDecals", "ps_6_0");
|
||||
}
|
||||
|
||||
static const D3D12_INPUT_ELEMENT_DESC kGLVertexInputLayout[] =
|
||||
@@ -9547,6 +9787,14 @@ static void QD3D12_CreatePSOs()
|
||||
d.BlendState.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_ONE;
|
||||
QD3D12_CHECK(g_gl.device->CreateGraphicsPipelineState(&d, IID_PPV_ARGS(&g_gl.postAdditivePSO)));
|
||||
|
||||
d.PS = { g_gl.postPsScreenDecalBlob->GetBufferPointer(), g_gl.postPsScreenDecalBlob->GetBufferSize() };
|
||||
d.BlendState.RenderTarget[0].BlendEnable = TRUE;
|
||||
d.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA;
|
||||
d.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA;
|
||||
d.BlendState.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_ONE;
|
||||
d.BlendState.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_INV_SRC_ALPHA;
|
||||
QD3D12_CHECK(g_gl.device->CreateGraphicsPipelineState(&d, IID_PPV_ARGS(&g_gl.postScreenDecalPSO)));
|
||||
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC depthDesc{};
|
||||
depthDesc.pRootSignature = g_gl.postRootSig.Get();
|
||||
depthDesc.VS = { g_gl.postVsBlob->GetBufferPointer(), g_gl.postVsBlob->GetBufferSize() };
|
||||
@@ -16328,6 +16576,8 @@ PROC WINAPI qd3d12_wglGetProcAddress(LPCSTR name) {
|
||||
{ "glRaytracingMaterialFlagQD3D12", (PROC)glRaytracingMaterialFlagQD3D12 },
|
||||
{ "glResolveGBufferQD3D12", (PROC)glResolveGBufferQD3D12 },
|
||||
{ "QD3D12_ResolveGBufferNow", (PROC)QD3D12_ResolveGBufferNow },
|
||||
{ "glSetScreenSpaceDecalsQD3D12",(PROC)glSetScreenSpaceDecalsQD3D12 },
|
||||
{ "glDrawScreenSpaceDecalsQD3D12",(PROC)glDrawScreenSpaceDecalsQD3D12 },
|
||||
{ "QD3D12_SetUpscalerBackend", (PROC)QD3D12_SetUpscalerBackend },
|
||||
{ "QD3D12_SetUpscalerQuality", (PROC)QD3D12_SetUpscalerQuality },
|
||||
{ "QD3D12_SetUpscalerSharpness", (PROC)QD3D12_SetUpscalerSharpness },
|
||||
|
||||
@@ -1728,6 +1728,21 @@ typedef struct glRaytracingLightingPassDesc_s
|
||||
uint32_t height;
|
||||
} glRaytracingLightingPassDesc_t;
|
||||
|
||||
typedef struct glScreenSpaceDecal_s
|
||||
{
|
||||
glRaytracingVec3_t origin;
|
||||
float halfSize;
|
||||
glRaytracingVec3_t normal;
|
||||
float depth;
|
||||
glRaytracingVec3_t axisU;
|
||||
float opacity;
|
||||
glRaytracingVec3_t axisV;
|
||||
float pad0;
|
||||
float color[4];
|
||||
uint32_t textureId;
|
||||
float pad1[3];
|
||||
} glScreenSpaceDecal_t;
|
||||
|
||||
int glRaytracingInit(void);
|
||||
void glRaytracingShutdown(void);
|
||||
void glRaytracingClear(void);
|
||||
@@ -1821,6 +1836,8 @@ glRaytracingLight_t glRaytracingLightingMakeRectLight(
|
||||
uint32_t glRaytracingLightingGetLightCount(void);
|
||||
|
||||
void glLightScene(glRaytracingSceneHandle_t sceneHandle);
|
||||
void glSetScreenSpaceDecalsQD3D12(const glScreenSpaceDecal_t* decals, uint32_t decalCount);
|
||||
void glDrawScreenSpaceDecalsQD3D12(void);
|
||||
|
||||
ID3D12Device* QD3D12_GetDevice(void);
|
||||
ID3D12CommandQueue* QD3D12_GetQueue(void);
|
||||
|
||||
Reference in New Issue
Block a user