ShaderModule: Don't create an inspector just to reflect exts
Bug: tint:1472 Change-Id: Ifc170c3da531dd17015f0f36dfccfaa8e250b50c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89403 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
c167ae12aa
commit
4b6d3f4346
|
@ -1238,7 +1238,7 @@ void DeviceBase::SetWGSLExtensionAllowList() {
|
|||
// mWGSLExtensionAllowList.insert("InternalExtensionForTesting");
|
||||
}
|
||||
|
||||
WGSLExtensionsSet DeviceBase::GetWGSLExtensionAllowList() const {
|
||||
WGSLExtensionSet DeviceBase::GetWGSLExtensionAllowList() const {
|
||||
return mWGSLExtensionAllowList;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ struct CallbackTask;
|
|||
struct InternalPipelineStore;
|
||||
struct ShaderModuleParseResult;
|
||||
|
||||
using WGSLExtensionsSet = std::unordered_set<std::string>;
|
||||
using WGSLExtensionSet = std::unordered_set<std::string>;
|
||||
|
||||
class DeviceBase : public RefCounted {
|
||||
public:
|
||||
|
@ -319,7 +319,7 @@ class DeviceBase : public RefCounted {
|
|||
std::mutex* GetObjectListMutex(ObjectType type);
|
||||
|
||||
std::vector<const char*> GetTogglesUsed() const;
|
||||
WGSLExtensionsSet GetWGSLExtensionAllowList() const;
|
||||
WGSLExtensionSet GetWGSLExtensionAllowList() const;
|
||||
bool IsFeatureEnabled(Feature feature) const;
|
||||
bool IsToggleEnabled(Toggle toggle) const;
|
||||
bool IsValidationEnabled() const;
|
||||
|
@ -549,7 +549,7 @@ class DeviceBase : public RefCounted {
|
|||
|
||||
CombinedLimits mLimits;
|
||||
FeaturesSet mEnabledFeatures;
|
||||
WGSLExtensionsSet mWGSLExtensionAllowList;
|
||||
WGSLExtensionSet mWGSLExtensionAllowList;
|
||||
|
||||
std::unique_ptr<InternalPipelineStore> mInternalPipelineStore;
|
||||
|
||||
|
|
|
@ -901,25 +901,20 @@ ResultOrError<std::unique_ptr<EntryPointMetadata>> ReflectEntryPointUsingTint(
|
|||
}
|
||||
|
||||
MaybeError ValidateWGSLProgramExtension(const DeviceBase* device,
|
||||
const tint::Program* program,
|
||||
const WGSLExtensionSet* enabledExtensions,
|
||||
OwnedCompilationMessages* outMessages) {
|
||||
DAWN_ASSERT(program->IsValid());
|
||||
tint::inspector::Inspector inspector(program);
|
||||
auto enableDirectives = inspector.GetEnableDirectives();
|
||||
|
||||
auto extensionAllowList = device->GetWGSLExtensionAllowList();
|
||||
const WGSLExtensionSet& extensionAllowList = device->GetWGSLExtensionAllowList();
|
||||
|
||||
bool hasDisallowedExtension = false;
|
||||
tint::diag::List messages;
|
||||
|
||||
for (auto enable : enableDirectives) {
|
||||
if (extensionAllowList.count(enable.first)) {
|
||||
for (const std::string& extension : *enabledExtensions) {
|
||||
if (extensionAllowList.count(extension)) {
|
||||
continue;
|
||||
}
|
||||
hasDisallowedExtension = true;
|
||||
messages.add_error(tint::diag::System::Program,
|
||||
"Extension " + enable.first + " is not allowed on the Device.",
|
||||
enable.second);
|
||||
"Extension " + extension + " is not allowed on the Device.");
|
||||
}
|
||||
|
||||
if (hasDisallowedExtension) {
|
||||
|
@ -936,8 +931,8 @@ MaybeError ValidateWGSLProgramExtension(const DeviceBase* device,
|
|||
MaybeError ReflectShaderUsingTint(const DeviceBase* device,
|
||||
const tint::Program* program,
|
||||
OwnedCompilationMessages* compilationMessages,
|
||||
EntryPointMetadataTable& entryPointMetadataTable,
|
||||
WGSLExtensionsSet* enabledWGSLExtensions) {
|
||||
EntryPointMetadataTable* entryPointMetadataTable,
|
||||
WGSLExtensionSet* enabledWGSLExtensions) {
|
||||
ASSERT(program->IsValid());
|
||||
|
||||
tint::inspector::Inspector inspector(program);
|
||||
|
@ -947,8 +942,7 @@ MaybeError ReflectShaderUsingTint(const DeviceBase* device,
|
|||
for (std::string name : usedExtensionNames) {
|
||||
enabledWGSLExtensions->insert(name);
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateWGSLProgramExtension(device, program, compilationMessages));
|
||||
DAWN_TRY(ValidateWGSLProgramExtension(device, enabledWGSLExtensions, compilationMessages));
|
||||
|
||||
std::vector<tint::inspector::EntryPoint> entryPoints = inspector.GetEntryPoints();
|
||||
DAWN_INVALID_IF(inspector.has_error(), "Tint Reflection failure: Inspector: %s\n",
|
||||
|
@ -960,8 +954,8 @@ MaybeError ReflectShaderUsingTint(const DeviceBase* device,
|
|||
ReflectEntryPointUsingTint(device, &inspector, entryPoint),
|
||||
"processing entry point \"%s\".", entryPoint.name);
|
||||
|
||||
ASSERT(entryPointMetadataTable.count(entryPoint.name) == 0);
|
||||
entryPointMetadataTable[entryPoint.name] = std::move(metadata);
|
||||
ASSERT(entryPointMetadataTable->count(entryPoint.name) == 0);
|
||||
(*entryPointMetadataTable)[entryPoint.name] = std::move(metadata);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -1336,7 +1330,7 @@ MaybeError ShaderModuleBase::InitializeBase(ShaderModuleParseResult* parseResult
|
|||
mTintSource = std::move(parseResult->tintSource);
|
||||
|
||||
DAWN_TRY(ReflectShaderUsingTint(GetDevice(), mTintProgram.get(), compilationMessages,
|
||||
mEntryPoints, &mEnabledWGSLExtensions));
|
||||
&mEntryPoints, &mEnabledWGSLExtensions));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class VertexPulling;
|
|||
|
||||
namespace dawn::native {
|
||||
|
||||
using WGSLExtensionsSet = std::unordered_set<std::string>;
|
||||
using WGSLExtensionSet = std::unordered_set<std::string>;
|
||||
struct EntryPointMetadata;
|
||||
|
||||
// Base component type of an inter-stage variable
|
||||
|
@ -307,7 +307,7 @@ class ShaderModuleBase : public ApiObjectBase, public CachedObject {
|
|||
std::string mWgsl;
|
||||
|
||||
EntryPointMetadataTable mEntryPoints;
|
||||
WGSLExtensionsSet mEnabledWGSLExtensions;
|
||||
WGSLExtensionSet mEnabledWGSLExtensions;
|
||||
std::unique_ptr<tint::Program> mTintProgram;
|
||||
std::unique_ptr<TintSource> mTintSource; // Keep the tint::Source::File alive
|
||||
|
||||
|
|
Loading…
Reference in New Issue