mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Remove ShaderStage that doesn't exist in WebGPU.
Instead it is replaced by one enum in dawn_native and another in utils. BUG=dawn:22 Change-Id: I094a40c8d4e22b704e59aea60cbefd1f05c5352a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8800 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
06ab6e5b13
commit
2a1d8c2b1d
@@ -27,7 +27,7 @@ namespace dawn_native {
|
||||
|
||||
DAWN_TRY(device->ValidateObject(descriptor->layout));
|
||||
DAWN_TRY(ValidatePipelineStageDescriptor(device, descriptor->computeStage,
|
||||
descriptor->layout, dawn::ShaderStage::Compute));
|
||||
descriptor->layout, ShaderStage::Compute));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages) {
|
||||
BitSetIterator<kNumStages, ShaderStage> IterateStages(dawn::ShaderStageBit stages) {
|
||||
std::bitset<kNumStages> bits(static_cast<uint32_t>(stages));
|
||||
return BitSetIterator<kNumStages, dawn::ShaderStage>(bits);
|
||||
return BitSetIterator<kNumStages, ShaderStage>(bits);
|
||||
}
|
||||
|
||||
dawn::ShaderStageBit StageBit(dawn::ShaderStage stage) {
|
||||
dawn::ShaderStageBit StageBit(ShaderStage stage) {
|
||||
ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return static_cast<dawn::ShaderStageBit>(1 << static_cast<uint32_t>(stage));
|
||||
}
|
||||
|
||||
@@ -25,22 +25,24 @@
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Vertex) < kNumStages, "");
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Fragment) < kNumStages, "");
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Compute) < kNumStages, "");
|
||||
enum class ShaderStage { Vertex, Fragment, Compute };
|
||||
|
||||
static_assert(static_cast<uint32_t>(ShaderStage::Vertex) < kNumStages, "");
|
||||
static_assert(static_cast<uint32_t>(ShaderStage::Fragment) < kNumStages, "");
|
||||
static_assert(static_cast<uint32_t>(ShaderStage::Compute) < kNumStages, "");
|
||||
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Vertex) ==
|
||||
(1 << static_cast<uint32_t>(dawn::ShaderStage::Vertex)),
|
||||
(1 << static_cast<uint32_t>(ShaderStage::Vertex)),
|
||||
"");
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Fragment) ==
|
||||
(1 << static_cast<uint32_t>(dawn::ShaderStage::Fragment)),
|
||||
(1 << static_cast<uint32_t>(ShaderStage::Fragment)),
|
||||
"");
|
||||
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Compute) ==
|
||||
(1 << static_cast<uint32_t>(dawn::ShaderStage::Compute)),
|
||||
(1 << static_cast<uint32_t>(ShaderStage::Compute)),
|
||||
"");
|
||||
|
||||
BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages);
|
||||
dawn::ShaderStageBit StageBit(dawn::ShaderStage stage);
|
||||
BitSetIterator<kNumStages, ShaderStage> IterateStages(dawn::ShaderStageBit stages);
|
||||
dawn::ShaderStageBit StageBit(ShaderStage stage);
|
||||
|
||||
static constexpr dawn::ShaderStageBit kAllStages =
|
||||
static_cast<dawn::ShaderStageBit>((1 << kNumStages) - 1);
|
||||
@@ -53,11 +55,11 @@ namespace dawn_native {
|
||||
mData.fill(initialValue);
|
||||
}
|
||||
|
||||
T& operator[](dawn::ShaderStage stage) {
|
||||
T& operator[](ShaderStage stage) {
|
||||
DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return mData[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
const T& operator[](dawn::ShaderStage stage) const {
|
||||
const T& operator[](ShaderStage stage) const {
|
||||
DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return mData[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace dawn_native {
|
||||
MaybeError ValidatePipelineStageDescriptor(DeviceBase* device,
|
||||
const PipelineStageDescriptor* descriptor,
|
||||
const PipelineLayoutBase* layout,
|
||||
dawn::ShaderStage stage) {
|
||||
ShaderStage stage) {
|
||||
DAWN_TRY(device->ValidateObject(descriptor->module));
|
||||
|
||||
if (descriptor->entryPoint != std::string("main")) {
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace dawn_native {
|
||||
MaybeError ValidatePipelineStageDescriptor(DeviceBase* device,
|
||||
const PipelineStageDescriptor* descriptor,
|
||||
const PipelineLayoutBase* layout,
|
||||
dawn::ShaderStage stage);
|
||||
ShaderStage stage);
|
||||
|
||||
class PipelineBase : public ObjectBase {
|
||||
public:
|
||||
|
||||
@@ -274,9 +274,9 @@ namespace dawn_native {
|
||||
DAWN_TRY(ValidateVertexInputDescriptor(descriptor->vertexInput, &attributesSetMask));
|
||||
DAWN_TRY(ValidatePrimitiveTopology(descriptor->primitiveTopology));
|
||||
DAWN_TRY(ValidatePipelineStageDescriptor(device, descriptor->vertexStage,
|
||||
descriptor->layout, dawn::ShaderStage::Vertex));
|
||||
descriptor->layout, ShaderStage::Vertex));
|
||||
DAWN_TRY(ValidatePipelineStageDescriptor(device, descriptor->fragmentStage,
|
||||
descriptor->layout, dawn::ShaderStage::Fragment));
|
||||
descriptor->layout, ShaderStage::Fragment));
|
||||
DAWN_TRY(ValidateRasterizationStateDescriptor(descriptor->rasterizationState));
|
||||
|
||||
if ((descriptor->vertexStage->module->GetUsedVertexAttributes() & ~attributesSetMask)
|
||||
|
||||
@@ -102,13 +102,13 @@ namespace dawn_native {
|
||||
|
||||
switch (compiler.get_execution_model()) {
|
||||
case spv::ExecutionModelVertex:
|
||||
mExecutionModel = dawn::ShaderStage::Vertex;
|
||||
mExecutionModel = ShaderStage::Vertex;
|
||||
break;
|
||||
case spv::ExecutionModelFragment:
|
||||
mExecutionModel = dawn::ShaderStage::Fragment;
|
||||
mExecutionModel = ShaderStage::Fragment;
|
||||
break;
|
||||
case spv::ExecutionModelGLCompute:
|
||||
mExecutionModel = dawn::ShaderStage::Compute;
|
||||
mExecutionModel = ShaderStage::Compute;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@@ -153,7 +153,7 @@ namespace dawn_native {
|
||||
dawn::BindingType::StorageBuffer);
|
||||
|
||||
// Extract the vertex attributes
|
||||
if (mExecutionModel == dawn::ShaderStage::Vertex) {
|
||||
if (mExecutionModel == ShaderStage::Vertex) {
|
||||
for (const auto& attrib : resources.stage_inputs) {
|
||||
ASSERT(compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation));
|
||||
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
|
||||
@@ -176,7 +176,7 @@ namespace dawn_native {
|
||||
}
|
||||
}
|
||||
|
||||
if (mExecutionModel == dawn::ShaderStage::Fragment) {
|
||||
if (mExecutionModel == ShaderStage::Fragment) {
|
||||
// Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
|
||||
// all the location 0, causing a compile error.
|
||||
for (const auto& attrib : resources.stage_inputs) {
|
||||
@@ -198,7 +198,7 @@ namespace dawn_native {
|
||||
return mUsedVertexAttributes;
|
||||
}
|
||||
|
||||
dawn::ShaderStage ShaderModuleBase::GetExecutionModel() const {
|
||||
ShaderStage ShaderModuleBase::GetExecutionModel() const {
|
||||
ASSERT(!IsError());
|
||||
return mExecutionModel;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/PerStage.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
@@ -58,7 +59,7 @@ namespace dawn_native {
|
||||
|
||||
const ModuleBindingInfo& GetBindingInfo() const;
|
||||
const std::bitset<kMaxVertexAttributes>& GetUsedVertexAttributes() const;
|
||||
dawn::ShaderStage GetExecutionModel() const;
|
||||
ShaderStage GetExecutionModel() const;
|
||||
|
||||
bool IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout);
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace dawn_native {
|
||||
|
||||
ModuleBindingInfo mBindingInfo;
|
||||
std::bitset<kMaxVertexAttributes> mUsedVertexAttributes;
|
||||
dawn::ShaderStage mExecutionModel;
|
||||
ShaderStage mExecutionModel;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
@@ -312,13 +312,13 @@ namespace dawn_native { namespace d3d12 {
|
||||
const char* compileTarget = nullptr;
|
||||
D3D12_SHADER_BYTECODE* shader = nullptr;
|
||||
switch (stage) {
|
||||
case dawn::ShaderStage::Vertex:
|
||||
case ShaderStage::Vertex:
|
||||
module = ToBackend(descriptor->vertexStage->module);
|
||||
entryPoint = descriptor->vertexStage->entryPoint;
|
||||
shader = &descriptorD3D12.VS;
|
||||
compileTarget = "vs_5_1";
|
||||
break;
|
||||
case dawn::ShaderStage::Fragment:
|
||||
case ShaderStage::Fragment:
|
||||
module = ToBackend(descriptor->fragmentStage->module);
|
||||
entryPoint = descriptor->fragmentStage->entryPoint;
|
||||
shader = &descriptorD3D12.PS;
|
||||
|
||||
@@ -219,15 +219,15 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
if (hasVertStage) {
|
||||
vertIndex = pipelineLayout->GetBindingIndexInfo(
|
||||
dawn::ShaderStage::Vertex)[index][bindingIndex];
|
||||
ShaderStage::Vertex)[index][bindingIndex];
|
||||
}
|
||||
if (hasFragStage) {
|
||||
fragIndex = pipelineLayout->GetBindingIndexInfo(
|
||||
dawn::ShaderStage::Fragment)[index][bindingIndex];
|
||||
ShaderStage::Fragment)[index][bindingIndex];
|
||||
}
|
||||
if (hasComputeStage) {
|
||||
computeIndex = pipelineLayout->GetBindingIndexInfo(
|
||||
dawn::ShaderStage::Compute)[index][bindingIndex];
|
||||
ShaderStage::Compute)[index][bindingIndex];
|
||||
}
|
||||
|
||||
switch (layout.types[bindingIndex]) {
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace dawn_native { namespace metal {
|
||||
const ShaderModule* computeModule = ToBackend(descriptor->computeStage->module);
|
||||
const char* computeEntryPoint = descriptor->computeStage->entryPoint;
|
||||
ShaderModule::MetalFunctionData computeData = computeModule->GetFunction(
|
||||
computeEntryPoint, dawn::ShaderStage::Compute, ToBackend(GetLayout()));
|
||||
computeEntryPoint, ShaderStage::Compute, ToBackend(GetLayout()));
|
||||
|
||||
NSError* error = nil;
|
||||
mMtlComputePipelineState =
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
using BindingIndexInfo =
|
||||
std::array<std::array<uint32_t, kMaxBindingsPerGroup>, kMaxBindGroups>;
|
||||
const BindingIndexInfo& GetBindingIndexInfo(dawn::ShaderStage stage) const;
|
||||
const BindingIndexInfo& GetBindingIndexInfo(ShaderStage stage) const;
|
||||
|
||||
private:
|
||||
PerStage<BindingIndexInfo> mIndexInfo;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(
|
||||
dawn::ShaderStage stage) const {
|
||||
ShaderStage stage) const {
|
||||
return mIndexInfo[stage];
|
||||
}
|
||||
|
||||
|
||||
@@ -317,13 +317,13 @@ namespace dawn_native { namespace metal {
|
||||
const ShaderModule* vertexModule = ToBackend(descriptor->vertexStage->module);
|
||||
const char* vertexEntryPoint = descriptor->vertexStage->entryPoint;
|
||||
ShaderModule::MetalFunctionData vertexData = vertexModule->GetFunction(
|
||||
vertexEntryPoint, dawn::ShaderStage::Vertex, ToBackend(GetLayout()));
|
||||
vertexEntryPoint, ShaderStage::Vertex, ToBackend(GetLayout()));
|
||||
descriptorMTL.vertexFunction = vertexData.function;
|
||||
|
||||
const ShaderModule* fragmentModule = ToBackend(descriptor->fragmentStage->module);
|
||||
const char* fragmentEntryPoint = descriptor->fragmentStage->entryPoint;
|
||||
ShaderModule::MetalFunctionData fragmentData = fragmentModule->GetFunction(
|
||||
fragmentEntryPoint, dawn::ShaderStage::Fragment, ToBackend(GetLayout()));
|
||||
fragmentEntryPoint, ShaderStage::Fragment, ToBackend(GetLayout()));
|
||||
descriptorMTL.fragmentFunction = fragmentData.function;
|
||||
|
||||
if (HasDepthStencilAttachment()) {
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
};
|
||||
MetalFunctionData GetFunction(const char* functionName,
|
||||
dawn::ShaderStage functionStage,
|
||||
ShaderStage functionStage,
|
||||
const PipelineLayout* layout) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
namespace {
|
||||
|
||||
spv::ExecutionModel SpirvExecutionModelForStage(dawn::ShaderStage stage) {
|
||||
spv::ExecutionModel SpirvExecutionModelForStage(ShaderStage stage) {
|
||||
switch (stage) {
|
||||
case dawn::ShaderStage::Vertex:
|
||||
case ShaderStage::Vertex:
|
||||
return spv::ExecutionModelVertex;
|
||||
case dawn::ShaderStage::Fragment:
|
||||
case ShaderStage::Fragment:
|
||||
return spv::ExecutionModelFragment;
|
||||
case dawn::ShaderStage::Compute:
|
||||
case ShaderStage::Compute:
|
||||
return spv::ExecutionModelGLCompute;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@@ -48,7 +48,7 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName,
|
||||
dawn::ShaderStage functionStage,
|
||||
ShaderStage functionStage,
|
||||
const PipelineLayout* layout) const {
|
||||
spirv_cross::CompilerMSL compiler(mSpirv);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace dawn_native { namespace opengl {
|
||||
ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
|
||||
: ComputePipelineBase(device, descriptor) {
|
||||
PerStage<const ShaderModule*> modules(nullptr);
|
||||
modules[dawn::ShaderStage::Compute] = ToBackend(descriptor->computeStage->module);
|
||||
modules[ShaderStage::Compute] = ToBackend(descriptor->computeStage->module);
|
||||
|
||||
PipelineGL::Initialize(device->gl, ToBackend(descriptor->layout), modules);
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
namespace {
|
||||
|
||||
GLenum GLShaderType(dawn::ShaderStage stage) {
|
||||
GLenum GLShaderType(ShaderStage stage) {
|
||||
switch (stage) {
|
||||
case dawn::ShaderStage::Vertex:
|
||||
case ShaderStage::Vertex:
|
||||
return GL_VERTEX_SHADER;
|
||||
case dawn::ShaderStage::Fragment:
|
||||
case ShaderStage::Fragment:
|
||||
return GL_FRAGMENT_SHADER;
|
||||
case dawn::ShaderStage::Compute:
|
||||
case ShaderStage::Compute:
|
||||
return GL_COMPUTE_SHADER;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@@ -75,13 +75,13 @@ namespace dawn_native { namespace opengl {
|
||||
mProgram = gl.CreateProgram();
|
||||
|
||||
dawn::ShaderStageBit activeStages = dawn::ShaderStageBit::None;
|
||||
for (dawn::ShaderStage stage : IterateStages(kAllStages)) {
|
||||
for (ShaderStage stage : IterateStages(kAllStages)) {
|
||||
if (modules[stage] != nullptr) {
|
||||
activeStages |= StageBit(stage);
|
||||
}
|
||||
}
|
||||
|
||||
for (dawn::ShaderStage stage : IterateStages(activeStages)) {
|
||||
for (ShaderStage stage : IterateStages(activeStages)) {
|
||||
GLuint shader = CreateShader(gl, GLShaderType(stage), modules[stage]->GetSource());
|
||||
gl.AttachShader(mProgram, shader);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace dawn_native { namespace opengl {
|
||||
// Compute links between stages for combined samplers, then bind them to texture units
|
||||
{
|
||||
std::set<CombinedSampler> combinedSamplersSet;
|
||||
for (dawn::ShaderStage stage : IterateStages(activeStages)) {
|
||||
for (ShaderStage stage : IterateStages(activeStages)) {
|
||||
for (const auto& combined : modules[stage]->GetCombinedSamplerInfo()) {
|
||||
combinedSamplersSet.insert(combined);
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ namespace dawn_native { namespace opengl {
|
||||
mVertexArrayObject(0),
|
||||
mGlPrimitiveTopology(GLPrimitiveTopology(GetPrimitiveTopology())) {
|
||||
PerStage<const ShaderModule*> modules(nullptr);
|
||||
modules[dawn::ShaderStage::Vertex] = ToBackend(descriptor->vertexStage->module);
|
||||
modules[dawn::ShaderStage::Fragment] = ToBackend(descriptor->fragmentStage->module);
|
||||
modules[ShaderStage::Vertex] = ToBackend(descriptor->vertexStage->module);
|
||||
modules[ShaderStage::Fragment] = ToBackend(descriptor->fragmentStage->module);
|
||||
|
||||
PipelineGL::Initialize(device->gl, ToBackend(GetLayout()), modules);
|
||||
CreateVAOForVertexInput(descriptor->vertexInput);
|
||||
|
||||
Reference in New Issue
Block a user