dawn/native: Add support for feature "indirect-first-instance"
Bug: dawn:1197 Change-Id: I9042b2dc178dfc01201bff55a2f5e43de28d335e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90526 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Enrico Galli <enrico.galli@intel.com>
This commit is contained in:
parent
d1eb73419e
commit
1ee244b3d3
|
@ -1214,6 +1214,7 @@
|
|||
{"name": "depth24 unorm stencil8", "type": "bool", "default": "false"},
|
||||
{"name": "depth32 float stencil8", "type": "bool", "default": "false"},
|
||||
{"name": "chromium experimental dp4a", "type": "bool", "default": "false"},
|
||||
{"name": "indirect first instance", "type": "bool", "default": "false"},
|
||||
{"name": "invalid feature", "type": "bool", "default": "false"},
|
||||
{"name": "dawn internal usages", "type": "bool", "default": "false"},
|
||||
{"name": "dawn native", "type": "bool", "default": "false"},
|
||||
|
|
|
@ -78,6 +78,10 @@ static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{
|
|||
{"chromium-experimental-dp4a", "Support experimental DP4a instructions in WGSL",
|
||||
"https://bugs.chromium.org/p/tint/issues/detail?id=1497"},
|
||||
&WGPUDeviceProperties::chromiumExperimentalDp4a},
|
||||
{Feature::IndirectFirstInstance,
|
||||
{"indirect-first-instance", "Support non-zero first instance values on indirect draw calls",
|
||||
"https://bugs.chromium.org/p/dawn/issues/detail?id=1197"},
|
||||
&WGPUDeviceProperties::indirectFirstInstance},
|
||||
{Feature::DawnInternalUsages,
|
||||
{"dawn-internal-usages",
|
||||
"Add internal usages to resources to affect how the texture is allocated, but not "
|
||||
|
@ -117,6 +121,8 @@ Feature FromAPIFeature(wgpu::FeatureName feature) {
|
|||
return Feature::Depth24UnormStencil8;
|
||||
case wgpu::FeatureName::Depth32FloatStencil8:
|
||||
return Feature::Depth32FloatStencil8;
|
||||
case wgpu::FeatureName::IndirectFirstInstance:
|
||||
return Feature::IndirectFirstInstance;
|
||||
case wgpu::FeatureName::DawnShaderFloat16:
|
||||
return Feature::ShaderFloat16;
|
||||
case wgpu::FeatureName::DawnInternalUsages:
|
||||
|
@ -127,9 +133,6 @@ Feature FromAPIFeature(wgpu::FeatureName feature) {
|
|||
return Feature::DawnNative;
|
||||
case wgpu::FeatureName::ChromiumExperimentalDp4a:
|
||||
return Feature::ChromiumExperimentalDp4a;
|
||||
|
||||
case wgpu::FeatureName::IndirectFirstInstance:
|
||||
return Feature::InvalidEnum;
|
||||
}
|
||||
return Feature::InvalidEnum;
|
||||
}
|
||||
|
@ -152,6 +155,8 @@ wgpu::FeatureName ToAPIFeature(Feature feature) {
|
|||
return wgpu::FeatureName::Depth24UnormStencil8;
|
||||
case Feature::Depth32FloatStencil8:
|
||||
return wgpu::FeatureName::Depth32FloatStencil8;
|
||||
case Feature::IndirectFirstInstance:
|
||||
return wgpu::FeatureName::IndirectFirstInstance;
|
||||
case Feature::ShaderFloat16:
|
||||
return wgpu::FeatureName::DawnShaderFloat16;
|
||||
case Feature::DawnInternalUsages:
|
||||
|
|
|
@ -37,6 +37,7 @@ enum class Feature {
|
|||
Depth24UnormStencil8,
|
||||
Depth32FloatStencil8,
|
||||
ChromiumExperimentalDp4a,
|
||||
IndirectFirstInstance,
|
||||
|
||||
// Dawn-specific
|
||||
DawnInternalUsages,
|
||||
|
|
|
@ -43,6 +43,7 @@ constexpr uint64_t kWorkgroupSize = 64;
|
|||
constexpr uint32_t kDuplicateBaseVertexInstance = 1;
|
||||
constexpr uint32_t kIndexedDraw = 2;
|
||||
constexpr uint32_t kValidationEnabled = 4;
|
||||
constexpr uint32_t kIndirectFirstInstanceEnabled = 8;
|
||||
|
||||
// Equivalent to the BatchInfo struct defined in the shader below.
|
||||
struct BatchInfo {
|
||||
|
@ -64,6 +65,7 @@ static const char sRenderValidationShaderSource[] = R"(
|
|||
let kDuplicateBaseVertexInstance = 1u;
|
||||
let kIndexedDraw = 2u;
|
||||
let kValidationEnabled = 4u;
|
||||
let kIndirectFirstInstanceEnabled = 8u;
|
||||
|
||||
struct BatchInfo {
|
||||
numIndexBufferElementsLow: u32,
|
||||
|
@ -140,11 +142,13 @@ static const char sRenderValidationShaderSource[] = R"(
|
|||
}
|
||||
|
||||
let inputIndex = batch.indirectOffsets[id.x];
|
||||
// firstInstance is always the last parameter
|
||||
let firstInstance = inputParams.data[inputIndex + numIndirectParamsPerDrawCallInput() - 1u];
|
||||
if (firstInstance != 0u) {
|
||||
fail(id.x);
|
||||
return;
|
||||
if(!bool(batch.flags & kIndirectFirstInstanceEnabled)) {
|
||||
// firstInstance is always the last parameter
|
||||
let firstInstance = inputParams.data[inputIndex + numIndirectParamsPerDrawCallInput() - 1u];
|
||||
if (firstInstance != 0u) {
|
||||
fail(id.x);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bool(batch.flags & kIndexedDraw)) {
|
||||
|
@ -334,6 +338,9 @@ MaybeError EncodeIndirectDrawValidationCommands(DeviceBase* device,
|
|||
if (device->IsValidationEnabled()) {
|
||||
newPass.flags |= kValidationEnabled;
|
||||
}
|
||||
if (device->IsFeatureEnabled(Feature::IndirectFirstInstance)) {
|
||||
newPass.flags |= kIndirectFirstInstanceEnabled;
|
||||
}
|
||||
passes.push_back(std::move(newPass));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() {
|
|||
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
|
||||
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
||||
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
||||
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||
|
||||
if (GetBackend()->GetFunctions()->IsDXCAvailable()) {
|
||||
uint64_t dxcVersion = 0;
|
||||
|
|
|
@ -386,6 +386,8 @@ class Adapter : public AdapterBase {
|
|||
}
|
||||
#endif
|
||||
|
||||
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -247,6 +247,15 @@ class Adapter : public AdapterBase {
|
|||
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
||||
}
|
||||
|
||||
// Non-zero baseInstance requires at least desktop OpenGL 4.2, and it is not supported in
|
||||
// OpenGL ES OpenGL:
|
||||
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDrawElementsIndirect.xhtml
|
||||
// OpenGL ES:
|
||||
// https://www.khronos.org/registry/OpenGL-Refpages/es3/html/glDrawElementsIndirect.xhtml
|
||||
if (mFunctions.IsAtLeastGL(4, 2)) {
|
||||
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,10 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() {
|
|||
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
||||
}
|
||||
|
||||
if (mDeviceInfo.features.drawIndirectFirstInstance == VK_TRUE) {
|
||||
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||
}
|
||||
|
||||
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) &&
|
||||
mDeviceInfo.shaderIntegerDotProductProperties
|
||||
.integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE &&
|
||||
|
|
|
@ -63,6 +63,13 @@ class FirstIndexOffsetTests : public DawnTest {
|
|||
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
|
||||
}
|
||||
|
||||
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
|
||||
if (!SupportsFeatures({wgpu::FeatureName::IndirectFirstInstance})) {
|
||||
return {};
|
||||
}
|
||||
return {wgpu::FeatureName::IndirectFirstInstance};
|
||||
}
|
||||
|
||||
private:
|
||||
void TestImpl(DrawMode mode,
|
||||
CheckIndex checkIndex,
|
||||
|
|
Loading…
Reference in New Issue