diff --git a/pxr/imaging/hd/tokens.h b/pxr/imaging/hd/tokens.h index 26438478b2..9dd9ffdb34 100644 --- a/pxr/imaging/hd/tokens.h +++ b/pxr/imaging/hd/tokens.h @@ -231,7 +231,8 @@ PXR_NAMESPACE_OPEN_SCOPE (worldToViewMatrix) \ (worldToViewInverseMatrix) \ (stepSize) \ - (stepSizeLighting) + (stepSizeLighting) \ + (multisampleCount) // Deprecated. Use: HdStMaterialTagTokens #define HD_MATERIALTAG_TOKENS \ diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index 407f022a3e..e2122cb66a 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -201,6 +201,7 @@ pxr_library(hdSt shaders/meshWire.glslfx shaders/points.glslfx shaders/pointId.glslfx + shaders/pointDisk.glslfx shaders/ptexTexture.glslfx shaders/renderPass.glslfx shaders/renderPassShader.glslfx diff --git a/pxr/imaging/hdSt/basisCurves.cpp b/pxr/imaging/hdSt/basisCurves.cpp index 8a8810367a..594ae3ccae 100644 --- a/pxr/imaging/hdSt/basisCurves.cpp +++ b/pxr/imaging/hdSt/basisCurves.cpp @@ -359,6 +359,10 @@ HdStBasisCurves::_UpdateDrawItemGeometricShader( resourceRegistry->GetHgi()->GetCapabilities()-> IsSet(HgiDeviceCapabilitiesBitsMetalTessellation); + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + HdSt_BasisCurvesShaderKey shaderKey(curveType, curveBasis, drawStyle, @@ -368,7 +372,8 @@ HdStBasisCurves::_UpdateDrawItemGeometricShader( shadingTerminal, hasAuthoredTopologicalVisiblity, _pointsShadingEnabled, - hasMetalTessellation); + hasMetalTessellation, + nativeRoundPoints); TF_DEBUG(HD_RPRIM_UPDATED). Msg("HdStBasisCurves(%s) - Shader Key PrimType: %s\n ", diff --git a/pxr/imaging/hdSt/basisCurvesShaderKey.cpp b/pxr/imaging/hdSt/basisCurvesShaderKey.cpp index 405f4a39b5..53c8b29987 100644 --- a/pxr/imaging/hdSt/basisCurvesShaderKey.cpp +++ b/pxr/imaging/hdSt/basisCurvesShaderKey.cpp @@ -128,6 +128,12 @@ TF_DEFINE_PRIVATE_TOKENS( ((surfaceFS, "Fragment.Surface")) ((surfaceUnlitFS, "Fragment.SurfaceUnlit")) ((scalarOverrideFS, "Fragment.ScalarOverride")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); static TfToken HdSt_BasisToShaderKey(const TfToken& basis){ @@ -151,7 +157,8 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( TfToken shadingTerminal, bool hasAuthoredTopologicalVisibility, bool pointsShadingEnabled, - bool hasMetalTessellation) + bool hasMetalTessellation, + bool nativeRoundPoints) : useMetalTessellation(false) , glslfx(_tokens->baseGLSLFX) { @@ -201,8 +208,11 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( VS[vsIndex++] = _tokens->pointIdVS; VS[vsIndex++] = _tokens->pointIdSelDecodeUtilsVS; VS[vsIndex++] = _tokens->pointIdSelPointSelVS; + VS[vsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { VS[vsIndex++] = _tokens->pointIdNoneVS; + VS[vsIndex++] = _tokens->noPointSizeBiasVS; } VS[vsIndex] = TfToken(); @@ -485,11 +495,17 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( } FS[fsIndex++] = _tokens->scalarOverrideFS; - FS[fsIndex++] = isPrimTypePoints? - _tokens->pointIdFS : _tokens->pointIdFallbackFS; - + if (isPrimTypePoints) { + FS[fsIndex++] = _tokens->pointIdFS; + FS[fsIndex++] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + } else { + FS[fsIndex++] = _tokens->pointIdFallbackFS; + FS[fsIndex++] = _tokens->noDiskSampleMaskFS; + } + FS[fsIndex++] = hasAuthoredTopologicalVisibility? _tokens->topVisFS : - _tokens->topVisFallbackFS; + _tokens->topVisFallbackFS; if (drawStyle == HdSt_BasisCurvesShaderKey::WIRE || diff --git a/pxr/imaging/hdSt/basisCurvesShaderKey.h b/pxr/imaging/hdSt/basisCurvesShaderKey.h index 6a23d009dd..f40615f65f 100644 --- a/pxr/imaging/hdSt/basisCurvesShaderKey.h +++ b/pxr/imaging/hdSt/basisCurvesShaderKey.h @@ -59,7 +59,8 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey TfToken shadingTerminal, bool hasAuthoredTopologicalVisibility, bool pointsShadingEnabled, - bool hasMetalTessellation); + bool hasMetalTessellation, + bool nativeRoundPoints); HDST_API ~HdSt_BasisCurvesShaderKey(); @@ -83,12 +84,13 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey HdSt_GeometricShader::PrimitiveType primType; bool useMetalTessellation; TfToken glslfx; - TfToken VS[7]; + TfToken VS[8]; TfToken TCS[7]; TfToken TES[12]; TfToken PTCS[9]; TfToken PTVS[14]; - TfToken FS[8]; + TfToken GS[2]; + TfToken FS[9]; }; diff --git a/pxr/imaging/hdSt/codeGen.cpp b/pxr/imaging/hdSt/codeGen.cpp index 2f41936567..645644576c 100644 --- a/pxr/imaging/hdSt/codeGen.cpp +++ b/pxr/imaging/hdSt/codeGen.cpp @@ -3190,6 +3190,18 @@ HdSt_CodeGen::_CompileWithGeneratedHgiResources( HgiShaderKeywordTokens->hdBaryCoordNoPersp); } + if (_geometricShader->GetPrimitiveType() == + HdSt_GeometricShader::PrimitiveType::PRIM_POINTS && + !registry->GetHgi()->GetCapabilities()->IsSet( + HgiDeviceCapabilitiesBitsRoundPoints)) { + HgiShaderFunctionAddStageInput(&fsDesc, "gl_PointCoord", "vec2", + HgiShaderKeywordTokens->hdPointCoord); + HgiShaderFunctionAddStageInput(&fsDesc, "hd_SampleMaskIn", "uint", + HgiShaderKeywordTokens->hdSampleMaskIn); + HgiShaderFunctionAddStageOutput(&fsDesc, "hd_SampleMask", "uint", + HgiShaderKeywordTokens->hdSampleMask); + } + if (!glslProgram->CompileShader(fsDesc)) { return nullptr; } diff --git a/pxr/imaging/hdSt/mesh.cpp b/pxr/imaging/hdSt/mesh.cpp index 2e467b2673..cf6626795b 100644 --- a/pxr/imaging/hdSt/mesh.cpp +++ b/pxr/imaging/hdSt/mesh.cpp @@ -2617,6 +2617,10 @@ HdStMesh::_UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate, resourceRegistry->GetHgi()->GetCapabilities()-> IsSet(HgiDeviceCapabilitiesBitsMetalTessellation); + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + // create a shaderKey and set to the geometric shader. HdSt_MeshShaderKey shaderKey(primType, shadingTerminal, @@ -2638,7 +2642,8 @@ HdStMesh::_UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate, desc.enableScalarOverride, _pointsShadingEnabled, desc.forceOpaqueEdges, - desc.surfaceEdgeIds); + desc.surfaceEdgeIds, + nativeRoundPoints); HdSt_GeometricShaderSharedPtr geomShader = HdSt_GeometricShader::Create(shaderKey, resourceRegistry); @@ -3057,4 +3062,3 @@ HdStMesh::GetInitialDirtyBitsMask() const } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/meshShaderKey.cpp b/pxr/imaging/hdSt/meshShaderKey.cpp index 7de6b26a85..32b50699a3 100644 --- a/pxr/imaging/hdSt/meshShaderKey.cpp +++ b/pxr/imaging/hdSt/meshShaderKey.cpp @@ -136,6 +136,12 @@ TF_DEFINE_PRIVATE_TOKENS( ((pointShadedFS, "Fragment.PointShaded")) ((scalarOverrideFS, "Fragment.ScalarOverride")) ((noScalarOverrideFS, "Fragment.NoScalarOverride")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); HdSt_MeshShaderKey::HdSt_MeshShaderKey( @@ -159,7 +165,8 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( bool enableScalarOverride, bool pointsShadingEnabled, bool forceOpaqueEdges, - bool surfaceEdgeIds) + bool surfaceEdgeIds, + bool nativeRoundPoints) : primType(primitiveType) , cullStyle(cullStyle) , hasMirroredTransform(hasMirroredTransform) @@ -255,8 +262,11 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( VS[vsIndex++] = _tokens->pointIdVS; VS[vsIndex++] = _tokens->selDecodeUtils; VS[vsIndex++] = _tokens->selPointSelVS; + VS[vsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { VS[vsIndex++] = _tokens->pointIdNoneVS; + VS[vsIndex++] = _tokens->noPointSizeBiasVS; } VS[vsIndex++] = _tokens->mainVS; VS[vsIndex] = TfToken(); @@ -313,8 +323,11 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( PTVS[ptvsIndex++] = _tokens->pointIdVS; PTVS[ptvsIndex++] = _tokens->selDecodeUtils; PTVS[ptvsIndex++] = _tokens->selPointSelVS; + PTVS[ptvsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { PTVS[ptvsIndex++] = _tokens->pointIdNoneVS; + PTVS[ptvsIndex++] = _tokens->noPointSizeBiasVS; } if (hasCustomDisplacement) { @@ -579,10 +592,17 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( } // PointId mixin for point picking and selection - FS[fsIndex++] = isPrimTypePoints? _tokens->pointIdFS : - _tokens->pointIdFallbackFS; + if (isPrimTypePoints) { + FS[fsIndex++] = _tokens->pointIdFS; + FS[fsIndex++] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + } else { + FS[fsIndex++] = _tokens->pointIdFallbackFS; + FS[fsIndex++] = _tokens->noDiskSampleMaskFS; + } + FS[fsIndex++] = hasTopologicalVisibility? _tokens->topVisFS : - _tokens->topVisFallbackFS; + _tokens->topVisFallbackFS; // Triangles if (isPrimTypeTris && ptvsStageEnabled) { diff --git a/pxr/imaging/hdSt/meshShaderKey.h b/pxr/imaging/hdSt/meshShaderKey.h index b73a77887d..696565f0e2 100644 --- a/pxr/imaging/hdSt/meshShaderKey.h +++ b/pxr/imaging/hdSt/meshShaderKey.h @@ -50,7 +50,8 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey bool enableScalarOverride, bool pointsShadingEnabled, bool forceOpaqueEdges, - bool surfaceEdgeIds); + bool surfaceEdgeIds, + bool nativeRoundPoints); // Note: it looks like gcc 4.8 has a problem issuing // a wrong warning as "array subscript is above array bounds" @@ -103,13 +104,13 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey TfToken const *GetFS() const override { return FS; } TfToken glslfx; - TfToken VS[7]; + TfToken VS[8]; TfToken TCS[4]; TfToken TES[4]; TfToken PTCS[4]; - TfToken PTVS[12]; + TfToken PTVS[13]; TfToken GS[10]; - TfToken FS[22]; + TfToken FS[23]; }; diff --git a/pxr/imaging/hdSt/points.cpp b/pxr/imaging/hdSt/points.cpp index 1102458600..23a4e8ecb9 100644 --- a/pxr/imaging/hdSt/points.cpp +++ b/pxr/imaging/hdSt/points.cpp @@ -161,10 +161,15 @@ HdStPoints::_UpdateDrawItem(HdSceneDelegate *sceneDelegate, constantPrimvars, HdTokens->displayOpacity); } - HdSt_PointsShaderKey shaderKey; HdStResourceRegistrySharedPtr resourceRegistry = std::static_pointer_cast( sceneDelegate->GetRenderIndex().GetResourceRegistry()); + + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + + HdSt_PointsShaderKey shaderKey{nativeRoundPoints}; drawItem->SetGeometricShader( HdSt_GeometricShader::Create(shaderKey, resourceRegistry)); @@ -434,4 +439,3 @@ HdStPoints::_InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/pointsShaderKey.cpp b/pxr/imaging/hdSt/pointsShaderKey.cpp index bcb5456da1..27cddf89a4 100644 --- a/pxr/imaging/hdSt/pointsShaderKey.cpp +++ b/pxr/imaging/hdSt/pointsShaderKey.cpp @@ -32,25 +32,36 @@ TF_DEFINE_PRIVATE_TOKENS( // instancing ((instancing, "Instancing.Transform")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); -HdSt_PointsShaderKey::HdSt_PointsShaderKey() +HdSt_PointsShaderKey::HdSt_PointsShaderKey( + bool nativeRoundPoints) : glslfx(_tokens->baseGLSLFX) { VS[0] = _tokens->instancing; - VS[1] = _tokens->mainVS; - VS[2] = _tokens->pointIdVS; - VS[3] = _tokens->pointIdSelDecodeUtilsVS; - VS[4] = _tokens->pointIdSelPointSelVS; - VS[5] = TfToken(); + VS[1] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; + VS[2] = _tokens->mainVS; + VS[3] = _tokens->pointIdVS; + VS[4] = _tokens->pointIdSelDecodeUtilsVS; + VS[5] = _tokens->pointIdSelPointSelVS; + VS[6] = TfToken(); // Common must be first as it defines terminal interfaces FS[0] = _tokens->commonFS; FS[1] = _tokens->surfaceFS; FS[2] = _tokens->noScalarOverrideFS; - FS[3] = _tokens->mainFS; - FS[4] = _tokens->pointIdFS; - FS[5] = TfToken(); + FS[3] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + FS[4] = _tokens->mainFS; + FS[5] = _tokens->pointIdFS; + FS[6] = TfToken(); } HdSt_PointsShaderKey::~HdSt_PointsShaderKey() @@ -58,4 +69,3 @@ HdSt_PointsShaderKey::~HdSt_PointsShaderKey() } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/pointsShaderKey.h b/pxr/imaging/hdSt/pointsShaderKey.h index be71588de8..44505bcf7a 100644 --- a/pxr/imaging/hdSt/pointsShaderKey.h +++ b/pxr/imaging/hdSt/pointsShaderKey.h @@ -19,7 +19,7 @@ PXR_NAMESPACE_OPEN_SCOPE struct HdSt_PointsShaderKey : public HdSt_ShaderKey { HDST_API - HdSt_PointsShaderKey(); + HdSt_PointsShaderKey(bool nativeRoundPoints); HDST_API ~HdSt_PointsShaderKey(); @@ -33,8 +33,8 @@ struct HdSt_PointsShaderKey : public HdSt_ShaderKey } TfToken glslfx; - TfToken VS[6]; - TfToken FS[6]; + TfToken VS[7]; + TfToken FS[7]; }; diff --git a/pxr/imaging/hdSt/renderPassState.cpp b/pxr/imaging/hdSt/renderPassState.cpp index 189a0a7ee7..bea3ba3dc6 100644 --- a/pxr/imaging/hdSt/renderPassState.cpp +++ b/pxr/imaging/hdSt/renderPassState.cpp @@ -311,6 +311,9 @@ HdStRenderPassState::Prepare( bufferSpecs.emplace_back( HdShaderTokens->stepSizeLighting, HdTupleType{HdTypeFloat, 1}); + bufferSpecs.emplace_back( + HdShaderTokens->multisampleCount, + HdTupleType{HdTypeUInt32, 1}); if (_UseAlphaMask()) { bufferSpecs.emplace_back( @@ -431,6 +434,19 @@ HdStRenderPassState::Prepare( VtValue(_stepSizeLighting)) }; + uint32_t multisampleCount = 1; + if (const auto& aovBindings = GetAovBindings(); + !aovBindings.empty() && GetUseAovMultiSample()) { + if (const auto* renderBuffer = dynamic_cast( + aovBindings.front().renderBuffer)) { + multisampleCount = renderBuffer->GetMSAASampleCount(); + } + } + sources.push_back( + std::make_shared( + HdShaderTokens->multisampleCount, + VtValue(multisampleCount))); + if (_UseAlphaMask()) { sources.push_back( std::make_shared( @@ -837,7 +853,7 @@ _GetRenderBuffer(const HdRenderPassAovBinding& aov, return aov.renderBuffer; } - return + return dynamic_cast( renderIndex->GetBprim( HdPrimTypeTokens->renderBuffer, diff --git a/pxr/imaging/hdSt/shaders/basisCurves.glslfx b/pxr/imaging/hdSt/shaders/basisCurves.glslfx index f389a14a64..bb087c1978 100644 --- a/pxr/imaging/hdSt/shaders/basisCurves.glslfx +++ b/pxr/imaging/hdSt/shaders/basisCurves.glslfx @@ -13,6 +13,7 @@ #import $TOOLS/hdSt/shaders/instancing.glslfx #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx #import $TOOLS/hdSt/shaders/visibility.glslfx // Known issues: @@ -138,10 +139,12 @@ void SetTessFactors(float out0, float out1, float out2, float out3, // We will either generate a camera facing normal or use the authored normal. FORWARD_DECL(vec3 getNormal(MAT4 transform)); -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -164,7 +167,8 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); ProcessPointId(pointId); } @@ -216,10 +220,12 @@ vec3 getNormal(MAT4 transform, int index) --- -------------------------------------------------------------------------- -- glsl Curves.Vertex.Wire -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -239,8 +245,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} --- -------------------------------------------------------------------------- -- glsl Curves.CommonControl @@ -1177,6 +1185,8 @@ Coeffs evaluateBasis(float u, const vec4 cv[4]) void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); @@ -1226,6 +1236,8 @@ void main(void) FORWARD_DECL(vec3 fragmentNormal(vec3 position, vec3 normal, float v)); void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/shaders/mesh.glslfx b/pxr/imaging/hdSt/shaders/mesh.glslfx index 55bd9e871c..d57d0b1972 100644 --- a/pxr/imaging/hdSt/shaders/mesh.glslfx +++ b/pxr/imaging/hdSt/shaders/mesh.glslfx @@ -17,6 +17,7 @@ #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/edgeId.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx #import $TOOLS/hdSt/shaders/visibility.glslfx --- -------------------------------------------------------------------------- @@ -48,7 +49,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -94,7 +95,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -167,7 +168,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -251,7 +252,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -689,7 +690,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); const ivec3 patchParam = GetPatchParam(); @@ -872,7 +873,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); const ivec3 patchParam = GetPatchParam(); @@ -1474,6 +1475,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/shaders/pointDisk.glslfx b/pxr/imaging/hdSt/shaders/pointDisk.glslfx new file mode 100644 index 0000000000..3dac0dcd50 --- /dev/null +++ b/pxr/imaging/hdSt/shaders/pointDisk.glslfx @@ -0,0 +1,89 @@ +-- glslfx version 0.1 + +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +--- This is what an import might look like. +--- #import $TOOLS/hdSt/shaders/pointDisk.glslfx + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Vertex.PointSizeBias + +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Vertex.None + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Fragment.SampleMask + +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Fragment.None + +void ApplyDiskSampleMask() +{ + // do nothing +} + diff --git a/pxr/imaging/hdSt/shaders/points.glslfx b/pxr/imaging/hdSt/shaders/points.glslfx index 1e8ad2d623..f76e839d4c 100644 --- a/pxr/imaging/hdSt/shaders/points.glslfx +++ b/pxr/imaging/hdSt/shaders/points.glslfx @@ -13,6 +13,7 @@ #import $TOOLS/hdSt/shaders/instancing.glslfx #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx --- -------------------------------------------------------------------------- -- layout Point.Vertex @@ -106,6 +107,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -126,6 +128,8 @@ void main(void) void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp index c44c5867fb..5bcd42e928 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp @@ -387,8 +387,9 @@ int main(int argc, char *argv[]) /* enableScalarOverride */ true, /* isWidget */ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true), - instance, smoothNormals); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true), + instance, smoothNormals); success &= TestShader( registry, HdSt_MeshShaderKey( @@ -412,8 +413,9 @@ int main(int argc, char *argv[]) /* enableScalarOverride */ true, /* isWidget */ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true), - instance, smoothNormals); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true), + instance, smoothNormals); } // curves @@ -427,15 +429,16 @@ int main(int argc, char *argv[]) true, HdBasisCurvesReprDescTokens->surfaceShader, topologicalVisibility, - /* isWidget */ false, false), - instance, false); + /* isWidget */ false, + /* hasMetalTessellation */ false, + /* nativeRoundPoints */ true), + instance, false); } // points if (points) { - success &= TestShader(registry, - HdSt_PointsShaderKey(), - instance, false); + success &= TestShader(registry, HdSt_PointsShaderKey( + /* nativeRoundPoints */ false), instance, false); } if (success) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out index 955e677491..5d5af10729 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out @@ -3,10 +3,10 @@ #import $TOOLS/hdSt/shaders/basisCurves.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None"] } +"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None", "PointDisk.Vertex.None"] } , "tessControlShader" : { "source" : ["Curves.CommonData", "Curves.TessFactorsGLSL", "Curves.CommonControl", "Curves.Tess.CurveData.Wire", "Curves.TessControl.Cubic.Wire"] } , "tessEvalShader" : { "source" : ["Curves.CommonData", "Instancing.Transform", "Curves.Tess.CurveData.Wire", "Curves.TessEval.Cubic.Wire", "Curves.BezierBasis", "Curves.Cubic.VaryingInterpolation"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } }}} ------------------------------------------------------- ======================================================= @@ -29,6 +29,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -611,10 +613,12 @@ bool IsFlipped() } -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -634,8 +638,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} @@ -664,6 +670,14 @@ void ProcessPointId(int pointId) } + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + ======================================================= TESS CONTROL SHADER ======================================================= @@ -680,6 +694,8 @@ void ProcessPointId(int pointId) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1193,6 +1209,8 @@ void determineLODSettings(CurveData vertexData) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1948,6 +1966,8 @@ vec4 InterpolatePrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv2, vec4 inPv3, #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2632,6 +2652,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2641,6 +2668,8 @@ void DiscardBasedOnTopologicalVisibility() void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out index 86d45a5143..ba306608f0 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -641,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -657,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -687,6 +697,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2628,6 +2642,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2675,6 +2696,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2721,9 +2744,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2746,6 +2769,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3359,6 +3384,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3375,7 +3408,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3405,6 +3438,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4243,6 +4278,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5380,6 +5417,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5427,6 +5471,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out index abbd8a00e8..32cbf1baa4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -641,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -657,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -687,6 +697,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2634,6 +2648,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2681,6 +2702,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2727,9 +2750,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2752,6 +2775,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3365,6 +3390,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3381,7 +3414,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3411,6 +3444,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4249,6 +4284,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5392,6 +5429,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5439,6 +5483,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out index 250423a51c..d0f55f58f9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -641,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -657,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -687,6 +697,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2579,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2626,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2672,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2697,6 +2720,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3310,6 +3335,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3326,7 +3359,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3356,6 +3389,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4194,6 +4229,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5280,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5327,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out index 531ef99eea..c015cde4c2 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -641,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -657,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -687,6 +697,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2578,6 +2592,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2625,6 +2646,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2671,9 +2694,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2696,6 +2719,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3309,6 +3334,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3325,7 +3358,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3355,6 +3388,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4193,6 +4228,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5278,6 +5315,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5325,6 +5369,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out index 250423a51c..d0f55f58f9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -641,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -657,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -687,6 +697,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2579,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2626,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2672,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2697,6 +2720,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3310,6 +3335,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3326,7 +3359,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3356,6 +3389,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4194,6 +4229,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5280,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5327,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out index 30328f80d7..f95e3e2d35 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -691,6 +693,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -707,7 +717,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -737,6 +747,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1575,6 +1587,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2684,6 +2698,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2731,6 +2752,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2777,9 +2800,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2802,6 +2825,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3465,6 +3490,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3481,7 +3514,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3511,6 +3544,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4378,6 +4413,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5490,6 +5527,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5537,6 +5581,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out index abaa7580fd..f2217a7de4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -654,6 +656,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -670,7 +680,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -700,6 +710,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1496,6 +1508,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2579,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2626,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2672,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2697,6 +2720,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3323,6 +3348,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3339,7 +3372,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3369,6 +3402,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4194,6 +4229,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5280,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5327,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out index 074b689687..af2032fef9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out @@ -3,8 +3,8 @@ #import $TOOLS/hdSt/shaders/points.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "Point.Fragment", "PointId.Fragment.PointParam"] } +"vertexShader" : { "source" : ["Instancing.Transform", "PointDisk.Vertex.PointSizeBias", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "PointDisk.Fragment.SampleMask", "Point.Fragment", "PointId.Fragment.PointParam"] } }}} ------------------------------------------------------- ======================================================= @@ -27,6 +27,8 @@ int HgiGetBaseVertex() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -606,6 +608,32 @@ bool IsFlipped() } +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(void ProcessPointId(int)); @@ -686,6 +714,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -1105,6 +1134,8 @@ bool IsPointSelected(int pointId) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1750,8 +1781,42 @@ ScalarOverride GetScalarOverride() } +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + + + void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out index 5b7c6b3359..322aa9e2a4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out @@ -3,10 +3,10 @@ #import $TOOLS/hdSt/shaders/basisCurves.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None"] } +"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None", "PointDisk.Vertex.None"] } , "tessControlShader" : { "source" : ["Curves.CommonData", "Curves.TessFactorsGLSL", "Curves.CommonControl", "Curves.Tess.CurveData.Wire", "Curves.TessControl.Cubic.Wire"] } , "tessEvalShader" : { "source" : ["Curves.CommonData", "Instancing.Transform", "Curves.Tess.CurveData.Wire", "Curves.TessEval.Cubic.Wire", "Curves.BezierBasis", "Curves.Cubic.VaryingInterpolation"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } }}} ------------------------------------------------------- ======================================================= @@ -29,6 +29,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -608,10 +610,12 @@ bool IsFlipped() } -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -631,8 +635,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} @@ -661,6 +667,14 @@ void ProcessPointId(int pointId) } + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + ======================================================= TESS CONTROL SHADER ======================================================= @@ -674,6 +688,8 @@ void ProcessPointId(int pointId) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1182,6 +1198,8 @@ void determineLODSettings(CurveData vertexData) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1932,6 +1950,8 @@ vec4 InterpolatePrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv2, vec4 inPv3, #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2613,6 +2633,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2622,6 +2649,8 @@ void DiscardBasedOnTopologicalVisibility() void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out index 2a3b4cf9c2..2178002152 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -638,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -654,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -681,6 +691,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2614,6 +2628,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2661,6 +2682,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2707,9 +2730,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2732,6 +2755,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3342,6 +3367,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3358,7 +3391,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3385,6 +3418,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4218,6 +4253,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5352,6 +5389,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5399,6 +5443,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out index ac333842a2..6a723ed210 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -638,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -654,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -681,6 +691,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2620,6 +2634,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2667,6 +2688,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2713,9 +2736,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2738,6 +2761,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3348,6 +3373,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3364,7 +3397,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3391,6 +3424,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4224,6 +4259,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5364,6 +5401,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5411,6 +5455,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out index 27706fa6cd..0d0f15b96c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -638,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -654,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -681,6 +691,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2565,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2612,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2658,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2683,6 +2706,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3293,6 +3318,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3309,7 +3342,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3336,6 +3369,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4169,6 +4204,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5252,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5299,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out index fbb7744dce..2ae915a42e 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -638,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -654,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -681,6 +691,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2564,6 +2578,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2611,6 +2632,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2657,9 +2680,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2682,6 +2705,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3292,6 +3317,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3308,7 +3341,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3335,6 +3368,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4168,6 +4203,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5250,6 +5287,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5297,6 +5341,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out index 27706fa6cd..0d0f15b96c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -638,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -654,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -681,6 +691,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2565,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2612,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2658,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2683,6 +2706,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3293,6 +3318,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3309,7 +3342,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3336,6 +3369,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4169,6 +4204,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5252,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5299,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out index ae48e42cba..4b5de9bcb4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -688,6 +690,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -704,7 +714,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -731,6 +741,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1564,6 +1576,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2670,6 +2684,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2717,6 +2738,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2763,9 +2786,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2788,6 +2811,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3448,6 +3473,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3464,7 +3497,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3491,6 +3524,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4353,6 +4388,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5462,6 +5499,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5509,6 +5553,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out index e544b38e41..b001478b38 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -28,6 +28,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -651,6 +653,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -667,7 +677,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -694,6 +704,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1485,6 +1497,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -2565,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2612,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2658,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -2683,6 +2706,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -3306,6 +3331,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3322,7 +3355,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -3349,6 +3382,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -4169,6 +4204,8 @@ void main(void) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -5252,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5299,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out index 3dae5bf8e6..21542e95b9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out @@ -3,8 +3,8 @@ #import $TOOLS/hdSt/shaders/points.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "Point.Fragment", "PointId.Fragment.PointParam"] } +"vertexShader" : { "source" : ["Instancing.Transform", "PointDisk.Vertex.PointSizeBias", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "PointDisk.Fragment.SampleMask", "Point.Fragment", "PointId.Fragment.PointParam"] } }}} ------------------------------------------------------- ======================================================= @@ -27,6 +27,8 @@ int HgiGetBaseInstance() { #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -603,6 +605,32 @@ bool IsFlipped() } +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(void ProcessPointId(int)); @@ -683,6 +711,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -1099,6 +1128,8 @@ bool IsPointSelected(int pointId) #define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) #define atomic_int int #define atomic_uint uint +#define hd_SampleMaskIn gl_SampleMaskIn[0] +#define hd_SampleMask gl_SampleMask[0] #define HGI_HAS_DOUBLE_TYPE 1 @@ -1741,8 +1772,42 @@ ScalarOverride GetScalarOverride() } +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + + + void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp index 7f5e9ef24a..603f6d8501 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp @@ -218,7 +218,8 @@ _RegisterDrawItem( /*enableScalarOverride=*/ true, /*isWidget*/ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true); // need to register to get batching works HdSt_GeometricShaderSharedPtr const geomShader = @@ -707,7 +708,7 @@ EmptyDrawBatchTest(HdStResourceRegistrySharedPtr const ®istry) sharedData.bounds.SetRange(range); HdStDrawItem drawItem(&sharedData); - HdSt_PointsShaderKey shaderKey; + HdSt_PointsShaderKey shaderKey{/*nativeRoundPoints*/false}; // need to register to get batching works HdSt_GeometricShaderSharedPtr const geomShader = @@ -778,4 +779,3 @@ int main() return EXIT_FAILURE; } } - diff --git a/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp b/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp index 7005f497db..f457d63ad1 100644 --- a/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp @@ -249,7 +249,7 @@ My_TestGLDrawing::DrawTest() _tokens->glslfxFilename, _tokens->defaultToken); HdStShaderCodeSharedPtrVector shaders = { renderPassShader, shader }; - HdSt_PointsShaderKey shaderKey = HdSt_PointsShaderKey(); + HdSt_PointsShaderKey shaderKey{/*nativeRoundPoints*/false}; // Create the geometric shader. HdInstance geometricShaderInstance = diff --git a/pxr/imaging/hdx/taskController.cpp b/pxr/imaging/hdx/taskController.cpp index 45737d1479..f9963b2aaf 100644 --- a/pxr/imaging/hdx/taskController.cpp +++ b/pxr/imaging/hdx/taskController.cpp @@ -73,8 +73,8 @@ TF_DEFINE_PRIVATE_TOKENS( (PxrDomeLight) ); -// XXX: WBN to expose this to the application. -static const uint32_t MSAA_SAMPLE_COUNT = 4; +TF_DEFINE_ENV_SETTING(HDX_MSAA_SAMPLE_COUNT, 4, + "MSAA sample count. Set to 1 to disable MSAA."); // Distant Light values static const float DISTANT_LIGHT_ANGLE = 0.53; @@ -1055,6 +1055,8 @@ HdxTaskController::SetRenderOutputs(TfTokenVector const& outputs) } } + const uint32_t msaaSampleCount = + std::clamp(TfGetEnvSetting(HDX_MSAA_SAMPLE_COUNT), 1, 16); // Add the new renderbuffers. _GetAovPath returns ids of the form // {controller_id}/aov_{name}. for (size_t i = 0; i < localOutputs.size(); ++i) { @@ -1064,11 +1066,15 @@ HdxTaskController::SetRenderOutputs(TfTokenVector const& outputs) HdRenderBufferDescriptor desc; desc.dimensions = dimensions3; desc.format = outputDescs[i].format; - desc.multiSampled = outputDescs[i].multiSampled; + if (msaaSampleCount > 1) { + desc.multiSampled = outputDescs[i].multiSampled; + } else { + desc.multiSampled = false; + } _delegate.SetParameter(aovId, _tokens->renderBufferDescriptor,desc); _delegate.SetParameter(aovId, HdStRenderBufferTokens->stormMsaaSampleCount, - MSAA_SAMPLE_COUNT); + msaaSampleCount); GetRenderIndex()->GetChangeTracker().MarkBprimDirty(aovId, HdRenderBuffer::DirtyDescription); _aovBufferIds.push_back(aovId); diff --git a/pxr/imaging/hgi/enums.h b/pxr/imaging/hgi/enums.h index 5811b2c598..ca300584c2 100644 --- a/pxr/imaging/hgi/enums.h +++ b/pxr/imaging/hgi/enums.h @@ -58,6 +58,8 @@ using HgiBits = uint32_t; /// The device requires workaround for primitive id ///
  • HgiDeviceCapabilitiesBitsIndirectCommandBuffers: /// Indirect command buffers are supported
  • +///
  • HgiDeviceCapabilitiesBitsRoundPoints: +/// Points can be natively rasterized as disks
  • /// /// enum HgiDeviceCapabilitiesBits : HgiBits @@ -80,6 +82,7 @@ enum HgiDeviceCapabilitiesBits : HgiBits HgiDeviceCapabilitiesBitsBasePrimitiveOffset = 1 << 15, HgiDeviceCapabilitiesBitsPrimitiveIdEmulation = 1 << 16, HgiDeviceCapabilitiesBitsIndirectCommandBuffers = 1 << 17, + HgiDeviceCapabilitiesBitsRoundPoints = 1 << 18, }; using HgiDeviceCapabilities = HgiBits; diff --git a/pxr/imaging/hgi/tokens.h b/pxr/imaging/hgi/tokens.h index ce1c4ad4ae..9a5614f206 100644 --- a/pxr/imaging/hgi/tokens.h +++ b/pxr/imaging/hgi/tokens.h @@ -43,6 +43,8 @@ TF_DECLARE_PUBLIC_TOKENS(HgiTokens, HGI_API, HGI_TOKENS); (hdPatchID) \ (hdGlobalInvocationID) \ (hdBaryCoordNoPersp) \ + (hdSampleMaskIn) \ + (hdSampleMask) \ TF_DECLARE_PUBLIC_TOKENS( HgiShaderKeywordTokens, HGI_API, HGI_SHADER_KEYWORD_TOKENS); diff --git a/pxr/imaging/hgiGL/capabilities.cpp b/pxr/imaging/hgiGL/capabilities.cpp index 4dc54436f6..df295385ce 100644 --- a/pxr/imaging/hgiGL/capabilities.cpp +++ b/pxr/imaging/hgiGL/capabilities.cpp @@ -191,6 +191,8 @@ HgiGLCapabilities::_LoadCapabilities() true); _SetFlag(HgiDeviceCapabilitiesBitsCustomDepthRange, true); + _SetFlag(HgiDeviceCapabilitiesBitsRoundPoints, + true); if (TfDebug::IsEnabled(HGI_DEBUG_DEVICE_CAPABILITIES)) { std::cout diff --git a/pxr/imaging/hgiGL/shaderGenerator.cpp b/pxr/imaging/hgiGL/shaderGenerator.cpp index 6d9e10b4c2..1bc8dcadac 100644 --- a/pxr/imaging/hgiGL/shaderGenerator.cpp +++ b/pxr/imaging/hgiGL/shaderGenerator.cpp @@ -253,7 +253,9 @@ HgiGLShaderGenerator::_WriteMacros(std::ostream &ss) "#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, " "expected, desired)\n" "#define atomic_int int\n" - "#define atomic_uint uint\n"; + "#define atomic_uint uint\n" + "#define hd_SampleMaskIn gl_SampleMaskIn[0]\n" + "#define hd_SampleMask gl_SampleMask[0]\n"; // Advertise to shader code that we support double precision math ss << "\n" @@ -371,6 +373,7 @@ HgiGLShaderGenerator::_WriteInOuts( "gl_FragColor", "gl_FragDepth", "gl_PointSize", + "hd_SampleMask", }; const static std::unordered_map takenInParams { @@ -391,6 +394,7 @@ HgiGLShaderGenerator::_WriteInOuts( { HgiShaderKeywordTokens->hdViewportIndex, "gl_ViewportIndex"}, { HgiShaderKeywordTokens->hdGlobalInvocationID, "gl_GlobalInvocationID"}, { HgiShaderKeywordTokens->hdBaryCoordNoPersp, "gl_BaryCoordNoPerspNV"}, + { HgiShaderKeywordTokens->hdSampleMaskIn, "hd_SampleMaskIn"} }; const bool in_qualifier = qualifier == "in"; diff --git a/pxr/imaging/hgiMetal/shaderGenerator.mm b/pxr/imaging/hgiMetal/shaderGenerator.mm index f076b3c09c..f1db1beb1d 100644 --- a/pxr/imaging/hgiMetal/shaderGenerator.mm +++ b/pxr/imaging/hgiMetal/shaderGenerator.mm @@ -150,7 +150,7 @@ HgiMetalShaderSectionPtrVector AccumulateTextureBindings( } bool -_GetBuiltinKeyword(HgiShaderFunctionParamDesc const ¶m, +_GetBuiltinInputKeyword(HgiShaderFunctionParamDesc const ¶m, std::string *keyword = nullptr) { //possible metal attributes on shader inputs. @@ -167,7 +167,9 @@ HgiMetalShaderSectionPtrVector AccumulateTextureBindings( {HgiShaderKeywordTokens->hdFrontFacing, "front_facing"}, {HgiShaderKeywordTokens->hdPosition, "position"}, {HgiShaderKeywordTokens->hdBaryCoordNoPersp, "barycentric_coord"}, - {HgiShaderKeywordTokens->hdFragCoord, "position"} + {HgiShaderKeywordTokens->hdFragCoord, "position"}, + {HgiShaderKeywordTokens->hdPointCoord, "point_coord"}, + {HgiShaderKeywordTokens->hdSampleMaskIn, "sample_mask"}, }; //check if has a role @@ -180,7 +182,31 @@ HgiMetalShaderSectionPtrVector AccumulateTextureBindings( return true; } } - + + return false; +} + +bool +_GetBuiltinOutputKeyword(HgiShaderFunctionParamDesc const ¶m, + std::string *keyword = nullptr) +{ + // possible metal attributes on shader output. + // Map from descriptor to Metal + const static std::unordered_map roleIndexM { + {HgiShaderKeywordTokens->hdSampleMask, "sample_mask"}, + }; + + //check if has a role + if(!param.role.empty()) { + auto it = roleIndexM.find(param.role); + if (it != roleIndexM.end()) { + if (keyword) { + *keyword = it->second; + } + return true; + } + } + return false; } @@ -685,7 +711,7 @@ void _Init( }; for(const HgiShaderFunctionParamDesc &p : params) { - if (_GetBuiltinKeyword(p)) continue; + if (_GetBuiltinInputKeyword(p)) continue; //For metal, the role is the actual attribute so far std::string indexAsStr; //check if has a role @@ -701,11 +727,13 @@ void _Init( HgiShaderSectionAttributeVector attributes = {}; if (!p.role.empty()) { - attributes.push_back(HgiShaderSectionAttribute{p.role, indexAsStr}); + std::string role = p.role; + _GetBuiltinOutputKeyword(p, &role); + attributes.push_back(HgiShaderSectionAttribute{std::move(role), indexAsStr}); } else if (p.interstageSlot != -1) { std::string role = "user(slot" + std::to_string(p.interstageSlot) + ")"; - attributes.push_back(HgiShaderSectionAttribute{role, indexAsStr}); + attributes.push_back(HgiShaderSectionAttribute{std::move(role), indexAsStr}); } attributes.push_back(HgiShaderSectionAttribute{ @@ -725,7 +753,7 @@ void _Init( int nextLocation = 0; for (size_t i = 0; i < params.size(); i++) { const HgiShaderFunctionParamDesc &p = params[i]; - if (_GetBuiltinKeyword(p)) continue; + if (_GetBuiltinInputKeyword(p)) continue; const int location = (p.location != -1) ? p.location : nextLocation; @@ -1209,29 +1237,24 @@ void _Init( generator); } -//Instantiate special keyword shader sections based on the given descriptor +// Instantiate special keyword shader input sections based on the given +// descriptor void HgiMetalShaderGenerator::_BuildKeywordInputShaderSections( const HgiShaderFunctionDesc &descriptor) { - //possible metal attributes on shader inputs. - // Map from descriptor to Metal - std::unordered_map roleIndexM { - {HgiShaderKeywordTokens->hdGlobalInvocationID, "thread_position_in_grid"} - }; - const std::vector &inputs = descriptor.stageInputs; for (size_t i = 0; i < inputs.size(); ++i) { const HgiShaderFunctionParamDesc &p(inputs[i]); std::string msl_attrib; - if(_GetBuiltinKeyword(p, &msl_attrib)) { + if(_GetBuiltinInputKeyword(p, &msl_attrib)) { const std::string &keywordName = p.nameInShader; const HgiShaderSectionAttributeVector attributes = { HgiShaderSectionAttribute{msl_attrib, "" }}; - //Shader section vector on the generator + // Shader section vector on the generator // owns all sections, point to it in the vector CreateShaderSection( keywordName, @@ -1296,7 +1319,7 @@ void _Init( const ShaderStageData stageData(descriptor, this); std::stringstream functionAttributesSS = std::stringstream(); - + switch (descriptor.shaderStage) { case HgiShaderStageVertex: { return std::make_unique diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index e82c367024..754a8acb7c 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -18,12 +18,16 @@ PXR_NAMESPACE_OPEN_SCOPE +TF_DEFINE_ENV_SETTING(HGIVULKAN_PREFERRED_DEVICE_TYPE, + VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, + "Preferred device type. Use VkPhysicalDeviceType enum values."); static uint32_t _GetGraphicsQueueFamilyIndex(VkPhysicalDevice physicalDevice) { uint32_t queueCount = 0; - vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueCount, 0); + vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueCount, + nullptr); std::vector queues(queueCount); vkGetPhysicalDeviceQueueFamilyProperties( @@ -84,6 +88,8 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) physicalDevices) ); + const auto preferredDeviceType = static_cast( + TfGetEnvSetting(HGIVULKAN_PREFERRED_DEVICE_TYPE)); for (uint32_t i = 0; i < physicalDeviceCount; i++) { VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(physicalDevices[i], &props); @@ -100,14 +106,15 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) if (props.apiVersion < VK_API_VERSION_1_0) continue; - // Try to find a discrete device. Until we find a discrete device, - // store the first non-discrete device as fallback in case we never - // find a discrete device at all. - if (props.deviceType==VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { + // Try to find a preferred device type. Until we find one, store the + // first non-preferred device as fallback in case we never find a + // preferred device at all. + if (props.deviceType == preferredDeviceType) { _vkPhysicalDevice = physicalDevices[i]; _vkGfxsQueueFamilyIndex = familyIndex; break; - } else if (!_vkPhysicalDevice) { + } + if (!_vkPhysicalDevice) { _vkPhysicalDevice = physicalDevices[i]; _vkGfxsQueueFamilyIndex = familyIndex; } @@ -409,4 +416,4 @@ HgiVulkanDevice::IsSupportedExtension(const char* extensionName) const } -PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hgiVulkan/shaderGenerator.cpp b/pxr/imaging/hgiVulkan/shaderGenerator.cpp index dd5509e164..b0cd30115e 100644 --- a/pxr/imaging/hgiVulkan/shaderGenerator.cpp +++ b/pxr/imaging/hgiVulkan/shaderGenerator.cpp @@ -228,7 +228,9 @@ HgiVulkanShaderGenerator::_WriteMacros(std::ostream &ss) "#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, " "expected, desired)\n" "#define atomic_int int\n" - "#define atomic_uint uint\n"; + "#define atomic_uint uint\n" + "#define hd_SampleMaskIn gl_SampleMaskIn[0]\n" + "#define hd_SampleMask gl_SampleMask[0]\n"; // Advertise to shader code that we support double precision math ss << "\n" @@ -347,6 +349,7 @@ HgiVulkanShaderGenerator::_WriteInOuts( "gl_FragDepth", "gl_PointSize", "gl_CullDistance", + "hd_SampleMask", }; // Some params are built-in, but we may want to declare them in the shader @@ -372,7 +375,8 @@ HgiVulkanShaderGenerator::_WriteInOuts( { HgiShaderKeywordTokens->hdLayer, "gl_Layer"}, { HgiShaderKeywordTokens->hdViewportIndex, "gl_ViewportIndex"}, { HgiShaderKeywordTokens->hdGlobalInvocationID, "gl_GlobalInvocationID"}, - { HgiShaderKeywordTokens->hdBaryCoordNoPersp, "gl_BaryCoordNoPerspEXT"} + { HgiShaderKeywordTokens->hdBaryCoordNoPersp, "gl_BaryCoordNoPerspEXT"}, + { HgiShaderKeywordTokens->hdSampleMaskIn, "hd_SampleMaskIn"} }; const bool in_qualifier = qualifier == "in"; diff --git a/pxr/usdImaging/usdImagingGL/CMakeLists.txt b/pxr/usdImaging/usdImagingGL/CMakeLists.txt index e932e367ec..23636c903e 100644 --- a/pxr/usdImaging/usdImagingGL/CMakeLists.txt +++ b/pxr/usdImaging/usdImagingGL/CMakeLists.txt @@ -5533,10 +5533,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance.usda -write testUsdImagingGLInstancing_instance.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5545,10 +5545,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance2.usda -write testUsdImagingGLInstancing_instance2.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance2.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5558,9 +5558,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance3.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5570,9 +5570,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_nestedInstance.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5581,10 +5581,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance.usda -write testUsdImagingGLInstancing_instance.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5593,10 +5593,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance2.usda -write testUsdImagingGLInstancing_instance2.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance2.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5606,9 +5606,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance3.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5618,9 +5618,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_nestedInstance.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ENV diff --git a/pxr/usdImaging/usdImagingGL/engine.cpp b/pxr/usdImaging/usdImagingGL/engine.cpp index bc822e8d1b..c1807f84b9 100644 --- a/pxr/usdImaging/usdImagingGL/engine.cpp +++ b/pxr/usdImaging/usdImagingGL/engine.cpp @@ -2015,4 +2015,3 @@ UsdImagingGLEngine::PollForAsynchronousUpdates() const } PXR_NAMESPACE_CLOSE_SCOPE -