Skip to content

Commit

Permalink
Stabilise Intel enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
EcosystemAdmin committed Sep 1, 2022
1 parent f80b9dd commit b2725cb
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 117 deletions.
14 changes: 0 additions & 14 deletions pxr/imaging/hdSt/codeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2316,16 +2316,6 @@ HdSt_CodeGen::_CompileWithGeneratedHgiResources(
HgiShaderKeywordTokens->hdPosition);

if (_hasPTVS) {
std::string vecSize = std::string();
if (_geometricShader->IsPrimTypeQuads() || _geometricShader->IsPrimTypeTriQuads()) {
vecSize = "vec2";
} else {
vecSize = "vec3";
}
HgiShaderFunctionAddStageInput(
&fsDesc, "ptvsBarycentricCoord", vecSize,
"");

HgiShaderFunctionAddStageInput(
&fsDesc, "patch_idOut", "uint",
"");
Expand Down Expand Up @@ -2484,10 +2474,6 @@ HdSt_CodeGen::_CompileWithGeneratedHgiResources(
HgiShaderFunctionAddStageOutput(
&ptvsDesc, "gl_Position", "vec4",
"position");

HgiShaderFunctionAddStageOutput(
&ptvsDesc, "ptvsBarycentricCoord", tessCoordType,
"");

char const* pointRole =
(_geometricShader->GetPrimitiveType() ==
Expand Down
18 changes: 14 additions & 4 deletions pxr/imaging/hdSt/pipelineDrawBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,12 @@ HdSt_PipelineDrawBatch::_CompileBatch(
TF_DEBUG(HDST_DRAW).Msg(" - useInstanceCulling: %d\n", _useInstanceCulling);
TF_DEBUG(HDST_DRAW).Msg(" - num draw items: %zu\n", numDrawItemInstances);

_drawCommandBuffer.resize(numDrawItemInstances * traits.numUInt32);
uint32_t drawCommandBufferPadding = 4 - (traits.numUInt32 % 4);
if (drawCommandBufferPadding == 4) {
drawCommandBufferPadding = 0;
}
uint32_t aligned = drawCommandBufferPadding + traits.numUInt32;
_drawCommandBuffer.resize(numDrawItemInstances * aligned);
std::vector<uint32_t>::iterator cmdIt = _drawCommandBuffer.begin();

// Count the number of visible items. We may actually draw fewer
Expand Down Expand Up @@ -797,6 +802,11 @@ HdSt_PipelineDrawBatch::_CompileBatch(
}
std::cout << std::endl;
}

//add Padding
for (uint32_t i = 0; i < drawCommandBufferPadding; i++) {
*cmdIt++ = 0;
}

_numVisibleItems += instanceCount;
_numTotalElements += numElements;
Expand All @@ -822,7 +832,7 @@ HdSt_PipelineDrawBatch::_CompileBatch(
_dispatchBuffer =
resourceRegistry->RegisterDispatchBuffer(_tokens->drawIndirect,
numDrawItemInstances,
traits.numUInt32);
traits.numUInt32 + drawCommandBufferPadding);

// add drawing resource views
_AddDrawResourceViews(_dispatchBuffer, traits);
Expand All @@ -839,7 +849,7 @@ HdSt_PipelineDrawBatch::_CompileBatch(
_dispatchBufferCullInput =
resourceRegistry->RegisterDispatchBuffer(_tokens->drawIndirectCull,
numDrawItemInstances,
traits.numUInt32);
traits.numUInt32 + drawCommandBufferPadding);

// add culling resource views
if (_useInstanceCulling) {
Expand Down Expand Up @@ -1243,7 +1253,7 @@ HdSt_PipelineDrawBatch::ExecuteDraw(
// the drawing batch and drawing program are prepared to resolve
// drawing coordinate state indirectly, i.e. from buffer data.
bool const drawIndirect =
capabilities->IsSet(HgiDeviceCapabilitiesBitsMultiDrawIndirect);
capabilities->IsSet(HgiDeviceCapabilitiesBitsMultiDrawIndirect);
_DrawingProgram & program = _GetDrawingProgram(renderPassState,
resourceRegistry);
if (!TF_VERIFY(program.IsValid())) return;
Expand Down
12 changes: 2 additions & 10 deletions pxr/imaging/hdSt/resourceRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

#include "pxr/imaging/hio/glslfx.h"
#include "pxr/imaging/hgi/hgi.h"
#include "pxr/imaging/hgi/enums.h"
#include "pxr/imaging/hgi/capabilities.h"

#include "pxr/base/tf/envSetting.h"
#include "pxr/base/tf/hash.h"
Expand Down Expand Up @@ -126,15 +124,9 @@ HdStResourceRegistry::HdStResourceRegistry(Hgi * const hgi)
, _numBufferSourcesToResolve(0)
// default aggregation strategies for varying (vertex, varying) primvars
, _nonUniformAggregationStrategy(
hgi->GetCapabilities()->IsSet(HgiDeviceCapabilitiesBitsPatchVertexOffsetting) ?
std::unique_ptr<HdAggregationStrategy>(std::make_unique<
HdStVBOSimpleMemoryManager>(this)) :
std::make_unique<HdStVBOMemoryManager>(this))
std::make_unique<HdStVBOMemoryManager>(this))
, _nonUniformImmutableAggregationStrategy(
hgi->GetCapabilities()->IsSet(HgiDeviceCapabilitiesBitsPatchVertexOffsetting) ?
std::unique_ptr<HdAggregationStrategy>(std::make_unique<
HdStVBOSimpleMemoryManager>(this)) :
std::make_unique<HdStVBOMemoryManager>(this))
std::make_unique<HdStVBOMemoryManager>(this))
// default aggregation strategy for uniform on UBO (for globals)
, _uniformUboAggregationStrategy(
std::make_unique<HdStInterleavedUBOMemoryManager>(this))
Expand Down
29 changes: 26 additions & 3 deletions pxr/imaging/hdSt/shaders/mesh.glslfx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ void main(void)
["out block", "VertexData", "outData",
["vec4", "Peye"],
["vec3", "Neye"]
]
],
["out", "vec3", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
Expand Down Expand Up @@ -148,7 +149,8 @@ void main(void)
["out block", "VertexData", "outData",
["vec4", "Peye"],
["vec3", "Neye"]
]
],
["out", "vec2", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
Expand Down Expand Up @@ -228,7 +230,8 @@ void main(void)
["out block", "VertexData", "outData",
["vec4", "Peye"],
["vec3", "Neye"]
]
],
["out", "vec2", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
Expand Down Expand Up @@ -932,6 +935,13 @@ vec3 GetPatchControlPoint()
return GetBarycentricCoord();
}

--- --------------------------------------------------------------------------
-- layout Mesh.Fragment.PatchCoord.ControlPointTessCoord.Triangle

[
["in", "vec3", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
-- glsl Mesh.Fragment.PatchCoord.ControlPointTessCoord.Triangle

Expand All @@ -940,6 +950,13 @@ vec3 GetPatchControlPoint()
return ptvsBarycentricCoord;
}

--- --------------------------------------------------------------------------
-- layout Mesh.Fragment.PatchCoord.ControlPointTessCoord.Quad

[
["in", "vec2", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
-- glsl Mesh.Fragment.PatchCoord.ControlPointTessCoord.Quad

Expand Down Expand Up @@ -1031,6 +1048,12 @@ vec4 GetInterpolatedPatchCoord()
return OsdInterpolatePatchCoord(GetPatchCoordLocalST(), GetPatchParam());
}

--- --------------------------------------------------------------------------
-- layout Mesh.Fragment.PatchCoord.TriQuadPTVS

[
["in", "vec2", "ptvsBarycentricCoord"]
]

--- --------------------------------------------------------------------------
-- glsl Mesh.Fragment.PatchCoord.TriQuadPTVS
Expand Down
12 changes: 2 additions & 10 deletions pxr/imaging/hdx/oitBufferAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include "pxr/imaging/hgiGL/buffer.h"

#include "pxr/imaging/hdx/tokens.h"
#include "pxr/imaging/hgi/hgi.h"
#include "pxr/imaging/hgi/capabilities.h"
#include "pxr/imaging/hgi/enums.h"

#include "pxr/base/tf/envSetting.h"

Expand All @@ -44,14 +41,9 @@ TF_DEFINE_ENV_SETTING(HDX_ENABLE_OIT, true,

/* static */
bool
HdxOitBufferAccessor::IsOitEnabled(Hgi *hgi)
HdxOitBufferAccessor::IsOitEnabled()
{
bool hasHgiOIT = true;
if (hgi != nullptr) {
hasHgiOIT = hgi->GetCapabilities()->IsSet(
HgiDeviceCapabilitiesBitsOIT);
}
return TfGetEnvSetting(HDX_ENABLE_OIT) && hasHgiOIT;
return TfGetEnvSetting(HDX_ENABLE_OIT);
}

HdxOitBufferAccessor::HdxOitBufferAccessor(HdTaskContext *ctx)
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hdx/oitBufferAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using HdStRenderPassShaderSharedPtr =
/// Class for OIT render tasks to access the OIT buffers.
class HdxOitBufferAccessor {
public:
static bool IsOitEnabled(Hgi *hgi);
static bool IsOitEnabled();

HDX_API
HdxOitBufferAccessor(HdTaskContext *ctx);
Expand Down
22 changes: 1 addition & 21 deletions pxr/imaging/hdx/oitRenderTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,11 @@
#include "pxr/imaging/hd/sceneDelegate.h"

#include "pxr/imaging/hdSt/renderPassShader.h"
#include "pxr/imaging/hgi/capabilities.h"

#include "pxr/imaging/glf/diagnostic.h"

PXR_NAMESPACE_OPEN_SCOPE

static Hgi* TryGetHgi(HdSceneDelegate* delegate) {
if (delegate == nullptr) {
return nullptr;
}
HdResourceRegistrySharedPtr resourceRegistry =
delegate->GetRenderIndex().GetResourceRegistry();
if (resourceRegistry == nullptr) {
return nullptr;
}
std::shared_ptr<HdStResourceRegistry> hdStResourceRegistry =
std::static_pointer_cast<HdStResourceRegistry>(
resourceRegistry);
if (hdStResourceRegistry == nullptr) {
return nullptr;
}
return hdStResourceRegistry->GetHgi();
}

HdxOitRenderTask::HdxOitRenderTask(HdSceneDelegate* delegate, SdfPath const& id)
: HdxRenderTask(delegate, id)
, _oitTranslucentRenderPassShader(
Expand All @@ -63,8 +44,7 @@ HdxOitRenderTask::HdxOitRenderTask(HdSceneDelegate* delegate, SdfPath const& id)
, _oitOpaqueRenderPassShader(
std::make_shared<HdStRenderPassShader>(
HdxPackageRenderPassOitOpaqueShader()))
, _isOitEnabled(TryGetHgi(delegate)->GetCapabilities()->IsSet(
HgiDeviceCapabilitiesBitsOIT))
, _isOitEnabled(HdxOitBufferAccessor::IsOitEnabled())
{
}

Expand Down
23 changes: 1 addition & 22 deletions pxr/imaging/hdx/oitVolumeRenderTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,17 @@
#include "pxr/imaging/hdSt/tokens.h"
#include "pxr/imaging/hdSt/volume.h"

#include "pxr/imaging/hgi/capabilities.h"

#include "pxr/imaging/glf/diagnostic.h"

PXR_NAMESPACE_OPEN_SCOPE

static Hgi* TryGetHgi(HdSceneDelegate* delegate) {
if (delegate == nullptr) {
return nullptr;
}
HdResourceRegistrySharedPtr resourceRegistry =
delegate->GetRenderIndex().GetResourceRegistry();
if (resourceRegistry == nullptr) {
return nullptr;
}
std::shared_ptr<HdStResourceRegistry> hdStResourceRegistry =
std::static_pointer_cast<HdStResourceRegistry>(
resourceRegistry);
if (hdStResourceRegistry == nullptr) {
return nullptr;
}
return hdStResourceRegistry->GetHgi();
}

HdxOitVolumeRenderTask::HdxOitVolumeRenderTask(
HdSceneDelegate* delegate, SdfPath const& id)
: HdxRenderTask(delegate, id)
, _oitVolumeRenderPassShader(
std::make_shared<HdStRenderPassShader>(
HdxPackageRenderPassOitVolumeShader()))
, _isOitEnabled(TryGetHgi(delegate)->GetCapabilities()
->IsSet(HgiDeviceCapabilitiesBitsOIT))
, _isOitEnabled(HdxOitBufferAccessor::IsOitEnabled())
{
}

Expand Down
6 changes: 2 additions & 4 deletions pxr/imaging/hgi/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ enum HgiDeviceCapabilitiesBits : HgiBits
HgiDeviceCapabilitiesBitsCustomDepthRange = 1 << 13,
HgiDeviceCapabilitiesBitsMetalTessellation = 1 << 14,
HgiDeviceCapabilitiesBitsBasePrimitiveOffset = 1 << 15,
HgiDeviceCapabilitiesBitsPatchVertexOffsetting = 1 << 16,
HgiDeviceCapabilitiesBitsTessellationBarycentric = 1 << 17,
HgiDeviceCapabilitiesBitsOIT = 1 << 18,
HgiDeviceCapabilitiesBitsPrimitiveIdEmulation = 1 << 19
HgiDeviceCapabilitiesBitsTessellationBarycentric = 1 << 16,
HgiDeviceCapabilitiesBitsPrimitiveIdEmulation = 1 << 17
};

using HgiDeviceCapabilities = HgiBits;
Expand Down
2 changes: 0 additions & 2 deletions pxr/imaging/hgiGL/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ HgiGLCapabilities::_LoadCapabilities()
true);
_SetFlag(HgiDeviceCapabilitiesBitsCustomDepthRange,
true);
_SetFlag(HgiDeviceCapabilitiesBitsOIT,
true);

if (TfDebug::IsEnabled(HGI_DEBUG_DEVICE_CAPABILITIES)) {
std::cout
Expand Down
17 changes: 2 additions & 15 deletions pxr/imaging/hgiMetal/capabilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,10 @@
_SetFlag(HgiDeviceCapabilitiesBitsConcurrentDispatch, true);
}

bool hasIntel = false;
//Gate intel on Mac by macOS 13.0
if (@available(macOS 13.0, *)) {
hasIntel = [device isLowPower];
}

_SetFlag(HgiDeviceCapabilitiesBitsOIT, true);

bool hasIntel = [device isLowPower];
if (hasIntel) {
bool vertexOffsettingFixes = true;
// Once IG driver issue is fixed, change to false.
if (@available(macOS 13.0, *)) {
vertexOffsettingFixes = false;
}
_SetFlag(HgiDeviceCapabilitiesBitsTessellationBarycentric, true);
_SetFlag(HgiDeviceCapabilitiesBitsPrimitiveIdEmulation, true);
_SetFlag(HgiDeviceCapabilitiesBitsPatchVertexOffsetting, vertexOffsettingFixes);
}

defaultStorageMode = MTLResourceStorageModeShared;
Expand Down Expand Up @@ -97,7 +84,7 @@
// if we are on MacOS 14 or less
//bool isMacOs13OrLess = NSProcessInfo.processInfo.operatingSystemVersion.majorVersion <= 13
//bool requireBasePrimitiveOffset = hasAppleSilicon && isMacOs13OrLess;
bool requiresBasePrimitiveOffset = hasAppleSilicon;
bool requiresBasePrimitiveOffset = hasAppleSilicon || hasIntel;
_SetFlag(HgiDeviceCapabilitiesBitsBasePrimitiveOffset,
requiresBasePrimitiveOffset);

Expand Down
12 changes: 1 addition & 11 deletions pxr/imaging/hgiMetal/hgi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,7 @@
bool
HgiMetal::IsBackendSupported() const
{
// Want Metal 2.0 and Metal Shading Language 2.2 or higher.
if (@available(macOS 10.15, ios 13.0, *)) {
// Only support devices with barycentrics.
return _capabilities->IsSet(
HgiDeviceCapabilitiesBitsBuiltinBarycentrics);
}
// Full Intel enablement if MacOS 13
if (@available(macOS 13.0, *)) {
return true;
}
return false;
return true;
}

id<MTLDevice>
Expand Down

0 comments on commit b2725cb

Please sign in to comment.