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": "depth24 unorm stencil8", "type": "bool", "default": "false"},
|
||||||
{"name": "depth32 float stencil8", "type": "bool", "default": "false"},
|
{"name": "depth32 float stencil8", "type": "bool", "default": "false"},
|
||||||
{"name": "chromium experimental dp4a", "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": "invalid feature", "type": "bool", "default": "false"},
|
||||||
{"name": "dawn internal usages", "type": "bool", "default": "false"},
|
{"name": "dawn internal usages", "type": "bool", "default": "false"},
|
||||||
{"name": "dawn native", "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",
|
{"chromium-experimental-dp4a", "Support experimental DP4a instructions in WGSL",
|
||||||
"https://bugs.chromium.org/p/tint/issues/detail?id=1497"},
|
"https://bugs.chromium.org/p/tint/issues/detail?id=1497"},
|
||||||
&WGPUDeviceProperties::chromiumExperimentalDp4a},
|
&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,
|
{Feature::DawnInternalUsages,
|
||||||
{"dawn-internal-usages",
|
{"dawn-internal-usages",
|
||||||
"Add internal usages to resources to affect how the texture is allocated, but not "
|
"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;
|
return Feature::Depth24UnormStencil8;
|
||||||
case wgpu::FeatureName::Depth32FloatStencil8:
|
case wgpu::FeatureName::Depth32FloatStencil8:
|
||||||
return Feature::Depth32FloatStencil8;
|
return Feature::Depth32FloatStencil8;
|
||||||
|
case wgpu::FeatureName::IndirectFirstInstance:
|
||||||
|
return Feature::IndirectFirstInstance;
|
||||||
case wgpu::FeatureName::DawnShaderFloat16:
|
case wgpu::FeatureName::DawnShaderFloat16:
|
||||||
return Feature::ShaderFloat16;
|
return Feature::ShaderFloat16;
|
||||||
case wgpu::FeatureName::DawnInternalUsages:
|
case wgpu::FeatureName::DawnInternalUsages:
|
||||||
|
@ -127,9 +133,6 @@ Feature FromAPIFeature(wgpu::FeatureName feature) {
|
||||||
return Feature::DawnNative;
|
return Feature::DawnNative;
|
||||||
case wgpu::FeatureName::ChromiumExperimentalDp4a:
|
case wgpu::FeatureName::ChromiumExperimentalDp4a:
|
||||||
return Feature::ChromiumExperimentalDp4a;
|
return Feature::ChromiumExperimentalDp4a;
|
||||||
|
|
||||||
case wgpu::FeatureName::IndirectFirstInstance:
|
|
||||||
return Feature::InvalidEnum;
|
|
||||||
}
|
}
|
||||||
return Feature::InvalidEnum;
|
return Feature::InvalidEnum;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +155,8 @@ wgpu::FeatureName ToAPIFeature(Feature feature) {
|
||||||
return wgpu::FeatureName::Depth24UnormStencil8;
|
return wgpu::FeatureName::Depth24UnormStencil8;
|
||||||
case Feature::Depth32FloatStencil8:
|
case Feature::Depth32FloatStencil8:
|
||||||
return wgpu::FeatureName::Depth32FloatStencil8;
|
return wgpu::FeatureName::Depth32FloatStencil8;
|
||||||
|
case Feature::IndirectFirstInstance:
|
||||||
|
return wgpu::FeatureName::IndirectFirstInstance;
|
||||||
case Feature::ShaderFloat16:
|
case Feature::ShaderFloat16:
|
||||||
return wgpu::FeatureName::DawnShaderFloat16;
|
return wgpu::FeatureName::DawnShaderFloat16;
|
||||||
case Feature::DawnInternalUsages:
|
case Feature::DawnInternalUsages:
|
||||||
|
|
|
@ -37,6 +37,7 @@ enum class Feature {
|
||||||
Depth24UnormStencil8,
|
Depth24UnormStencil8,
|
||||||
Depth32FloatStencil8,
|
Depth32FloatStencil8,
|
||||||
ChromiumExperimentalDp4a,
|
ChromiumExperimentalDp4a,
|
||||||
|
IndirectFirstInstance,
|
||||||
|
|
||||||
// Dawn-specific
|
// Dawn-specific
|
||||||
DawnInternalUsages,
|
DawnInternalUsages,
|
||||||
|
|
|
@ -43,6 +43,7 @@ constexpr uint64_t kWorkgroupSize = 64;
|
||||||
constexpr uint32_t kDuplicateBaseVertexInstance = 1;
|
constexpr uint32_t kDuplicateBaseVertexInstance = 1;
|
||||||
constexpr uint32_t kIndexedDraw = 2;
|
constexpr uint32_t kIndexedDraw = 2;
|
||||||
constexpr uint32_t kValidationEnabled = 4;
|
constexpr uint32_t kValidationEnabled = 4;
|
||||||
|
constexpr uint32_t kIndirectFirstInstanceEnabled = 8;
|
||||||
|
|
||||||
// Equivalent to the BatchInfo struct defined in the shader below.
|
// Equivalent to the BatchInfo struct defined in the shader below.
|
||||||
struct BatchInfo {
|
struct BatchInfo {
|
||||||
|
@ -64,6 +65,7 @@ static const char sRenderValidationShaderSource[] = R"(
|
||||||
let kDuplicateBaseVertexInstance = 1u;
|
let kDuplicateBaseVertexInstance = 1u;
|
||||||
let kIndexedDraw = 2u;
|
let kIndexedDraw = 2u;
|
||||||
let kValidationEnabled = 4u;
|
let kValidationEnabled = 4u;
|
||||||
|
let kIndirectFirstInstanceEnabled = 8u;
|
||||||
|
|
||||||
struct BatchInfo {
|
struct BatchInfo {
|
||||||
numIndexBufferElementsLow: u32,
|
numIndexBufferElementsLow: u32,
|
||||||
|
@ -140,12 +142,14 @@ static const char sRenderValidationShaderSource[] = R"(
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputIndex = batch.indirectOffsets[id.x];
|
let inputIndex = batch.indirectOffsets[id.x];
|
||||||
|
if(!bool(batch.flags & kIndirectFirstInstanceEnabled)) {
|
||||||
// firstInstance is always the last parameter
|
// firstInstance is always the last parameter
|
||||||
let firstInstance = inputParams.data[inputIndex + numIndirectParamsPerDrawCallInput() - 1u];
|
let firstInstance = inputParams.data[inputIndex + numIndirectParamsPerDrawCallInput() - 1u];
|
||||||
if (firstInstance != 0u) {
|
if (firstInstance != 0u) {
|
||||||
fail(id.x);
|
fail(id.x);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bool(batch.flags & kIndexedDraw)) {
|
if (!bool(batch.flags & kIndexedDraw)) {
|
||||||
pass(id.x);
|
pass(id.x);
|
||||||
|
@ -334,6 +338,9 @@ MaybeError EncodeIndirectDrawValidationCommands(DeviceBase* device,
|
||||||
if (device->IsValidationEnabled()) {
|
if (device->IsValidationEnabled()) {
|
||||||
newPass.flags |= kValidationEnabled;
|
newPass.flags |= kValidationEnabled;
|
||||||
}
|
}
|
||||||
|
if (device->IsFeatureEnabled(Feature::IndirectFirstInstance)) {
|
||||||
|
newPass.flags |= kIndirectFirstInstanceEnabled;
|
||||||
|
}
|
||||||
passes.push_back(std::move(newPass));
|
passes.push_back(std::move(newPass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() {
|
||||||
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
|
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
|
||||||
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
||||||
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
||||||
|
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||||
|
|
||||||
if (GetBackend()->GetFunctions()->IsDXCAvailable()) {
|
if (GetBackend()->GetFunctions()->IsDXCAvailable()) {
|
||||||
uint64_t dxcVersion = 0;
|
uint64_t dxcVersion = 0;
|
||||||
|
|
|
@ -386,6 +386,8 @@ class Adapter : public AdapterBase {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,15 @@ class Adapter : public AdapterBase {
|
||||||
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,10 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() {
|
||||||
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
mSupportedFeatures.EnableFeature(Feature::Depth32FloatStencil8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDeviceInfo.features.drawIndirectFirstInstance == VK_TRUE) {
|
||||||
|
mSupportedFeatures.EnableFeature(Feature::IndirectFirstInstance);
|
||||||
|
}
|
||||||
|
|
||||||
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) &&
|
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) &&
|
||||||
mDeviceInfo.shaderIntegerDotProductProperties
|
mDeviceInfo.shaderIntegerDotProductProperties
|
||||||
.integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE &&
|
.integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE &&
|
||||||
|
|
|
@ -63,6 +63,13 @@ class FirstIndexOffsetTests : public DawnTest {
|
||||||
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
|
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
|
||||||
|
if (!SupportsFeatures({wgpu::FeatureName::IndirectFirstInstance})) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {wgpu::FeatureName::IndirectFirstInstance};
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TestImpl(DrawMode mode,
|
void TestImpl(DrawMode mode,
|
||||||
CheckIndex checkIndex,
|
CheckIndex checkIndex,
|
||||||
|
|
Loading…
Reference in New Issue