Skip to content

Commit

Permalink
Merge branch 'pomCherryPick' into 'release/v0.6'
Browse files Browse the repository at this point in the history
REMIX-3574 run full safety checks before running POM

See merge request lightspeedrtx/dxvk-remix-nv!1066
  • Loading branch information
nsubtil committed Oct 11, 2024
2 parents d883e6e + 9128841 commit 070716c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 30 deletions.
7 changes: 6 additions & 1 deletion build_common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ If (Test-Path env:LIBPATH) {
Push-Location "${vsPath}\VC\Auxiliary\Build"
cmd /c "vcvarsall.bat x64&set" |
ForEach-Object {
# Due to some odd behavior with how powershell core (pwsh) (powershell 5.X not tested) interprets a specific
# predefined gitlab CI variable (in this case CI_MERGE_REQUEST_DESCRIPTION) with a value that includes ===
# The `Contains` method is used to ignore the string === to prevent pwsh from erroneously encountering an error.
If ($_ -match "=") {
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
If (-not ($_.Contains('==='))) {
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
}
}
}
Pop-Location
Expand Down
36 changes: 23 additions & 13 deletions src/dxvk/shaders/rtx/algorithm/integrator_indirect.slangh
Original file line number Diff line number Diff line change
Expand Up @@ -985,20 +985,30 @@ void integrateIndirectPath(
if (pathState.continuePath && cb.pomEnableIndirectLighting && geometryFlags.pomOpaqueSurfaceEncountered)
{
uint16_t primarySurfaceIndex = uint16_t(SharedSurfaceIndex[pixelCoordinate]);
const MemoryPolymorphicSurfaceMaterial memoryPolymorphicSurfaceMaterial = surfaceMaterials[primarySurfaceIndex];
OpaqueSurfaceMaterial opaqueSurfaceMaterial = opaqueSurfaceMaterialCreate(primarySurfaceIndex, memoryPolymorphicSurfaceMaterial);
if (primarySurfaceIndex != BINDING_INDEX_INVALID)
{
const MemoryPolymorphicSurfaceMaterial memoryPolymorphicSurfaceMaterial = surfaceMaterials[primarySurfaceIndex];
const uint8_t polymorphicType = memoryPolymorphicSurfaceMaterialGetTypeHelper(memoryPolymorphicSurfaceMaterial);
if (polymorphicType == surfaceMaterialTypeOpaque)
{
OpaqueSurfaceMaterial opaqueSurfaceMaterial = opaqueSurfaceMaterialCreate(primarySurfaceIndex, memoryPolymorphicSurfaceMaterial);

MinimalSurfaceInteraction minimalSurfaceInteraction = minimalSurfaceInteractionReadFromGBuffer(
pixelCoordinate, indirectPathTextures.PrimaryWorldPositionWorldTriangleNormal);

const float pomThroughput = opaqueSurfaceMaterialInteractionCalcHeightThroughput(
minimalSurfaceInteraction, pathState.direction, opaqueSurfaceMaterial.heightTextureIndex,
opaqueSurfaceMaterial.samplerIndex, SharedTextureCoord[pixelCoordinate], opaqueSurfaceMaterial.displaceIn
);

accumulateThroughput(pathState, pomThroughput);
pathState.continuePath = any(pathState.throughput > 0.001h);
pathState.continueResolving = pathState.continuePath;
if (opaqueSurfaceMaterial.heightTextureIndex != BINDING_INDEX_INVALID)
{
MinimalSurfaceInteraction minimalSurfaceInteraction = minimalSurfaceInteractionReadFromGBuffer(
pixelCoordinate, indirectPathTextures.PrimaryWorldPositionWorldTriangleNormal);

const float pomThroughput = opaqueSurfaceMaterialInteractionCalcHeightThroughput(
minimalSurfaceInteraction, pathState.direction, opaqueSurfaceMaterial.heightTextureIndex,
opaqueSurfaceMaterial.samplerIndex, SharedTextureCoord[pixelCoordinate], opaqueSurfaceMaterial.displaceIn
);

accumulateThroughput(pathState, pomThroughput);
pathState.continuePath = any(pathState.throughput > 0.001h);
pathState.continueResolving = pathState.continuePath;
}
}
}
}
#endif

Expand Down
42 changes: 26 additions & 16 deletions src/dxvk/shaders/rtx/algorithm/visibility.slangh
Original file line number Diff line number Diff line change
Expand Up @@ -454,23 +454,33 @@ VisibilityResult traceVisibilityRay<let VisibilityMode : uint>(
float pomAttenuation = 1.0f;
if ((VisibilityMode & visibilityModeEnablePom) && cb.pomMode != DisplacementMode::Off && pomOpaqueSurfaceEncountered)
{
const MemoryPolymorphicSurfaceMaterial memoryPolymorphicSurfaceMaterial = surfaceMaterials[primarySurfaceIndex];
OpaqueSurfaceMaterial opaqueSurfaceMaterial = opaqueSurfaceMaterialCreate(primarySurfaceIndex, memoryPolymorphicSurfaceMaterial);

pomAttenuation = opaqueSurfaceMaterialInteractionCalcHeightThroughput(
minimalSurfaceInteraction, visibilityRay.direction, opaqueSurfaceMaterial.heightTextureIndex,
opaqueSurfaceMaterial.samplerIndex, texCoords, opaqueSurfaceMaterial.displaceIn
);

if (pomAttenuation <= 0.001f)
if (primarySurfaceIndex != BINDING_INDEX_INVALID)
{
VisibilityResult result;
result.attenuation = pomAttenuation;
result.hasOpaqueHit = true;
result.rayDirection = visibilityRay.direction;
result.hitDistance = visibilityRay.tMax; // TODO should refactor POM code to return?
result.hasPOMHit = true;
return result;
const MemoryPolymorphicSurfaceMaterial memoryPolymorphicSurfaceMaterial = surfaceMaterials[primarySurfaceIndex];
const uint8_t polymorphicType = memoryPolymorphicSurfaceMaterialGetTypeHelper(memoryPolymorphicSurfaceMaterial);
if (polymorphicType == surfaceMaterialTypeOpaque)
{
OpaqueSurfaceMaterial opaqueSurfaceMaterial = opaqueSurfaceMaterialCreate(primarySurfaceIndex, memoryPolymorphicSurfaceMaterial);

if (opaqueSurfaceMaterial.heightTextureIndex != BINDING_INDEX_INVALID)
{
pomAttenuation = opaqueSurfaceMaterialInteractionCalcHeightThroughput(
minimalSurfaceInteraction, visibilityRay.direction, opaqueSurfaceMaterial.heightTextureIndex,
opaqueSurfaceMaterial.samplerIndex, texCoords, opaqueSurfaceMaterial.displaceIn
);

if (pomAttenuation <= 0.001f)
{
VisibilityResult result;
result.attenuation = pomAttenuation;
result.hasOpaqueHit = true;
result.rayDirection = visibilityRay.direction;
result.hitDistance = visibilityRay.tMax; // TODO should refactor POM code to return?
result.hasPOMHit = true;
return result;
}
}
}
}
}
#endif
Expand Down

0 comments on commit 070716c

Please sign in to comment.