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:
Corentin Wallez 2019-07-12 17:52:22 +00:00 committed by Commit Bot service account
parent 06ab6e5b13
commit 2a1d8c2b1d
65 changed files with 218 additions and 215 deletions

View File

@ -938,14 +938,6 @@
{"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size"}
]
},
"shader stage": {
"category": "enum",
"values": [
{"value": 0, "name": "vertex"},
{"value": 1, "name": "fragment"},
{"value": 2, "name": "compute"}
]
},
"shader stage bit": {
"category": "bitmask",
"values": [

View File

@ -55,7 +55,7 @@ void init() {
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
dawn::TextureUsageBit::OutputAttachment, 640, 480);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(std140, set = 0, binding = 0) uniform Constants {
@ -102,7 +102,8 @@ void init() {
gl_Position = vec4(xpos, ypos, 0.0, 1.0);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
layout(location = 0) in vec4 v_color;

View File

@ -44,7 +44,8 @@ void init() {
"void main() {\n"
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
"}\n";
DawnShaderModule vsModule = utils::CreateShaderModule(dawn::Device(device), dawn::ShaderStage::Vertex, vs).Release();
DawnShaderModule vsModule =
utils::CreateShaderModule(dawn::Device(device), utils::ShaderStage::Vertex, vs).Release();
const char* fs =
"#version 450\n"
@ -52,7 +53,8 @@ void init() {
"void main() {\n"
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
"}\n";
DawnShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
DawnShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fs).Release();
{
DawnRenderPipelineDescriptor descriptor;

View File

@ -94,7 +94,7 @@ void initBuffers() {
}
void initRender() {
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec2 a_particlePos;
layout(location = 1) in vec2 a_particleVel;
@ -107,7 +107,8 @@ void initRender() {
}
)");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
@ -143,7 +144,7 @@ void initRender() {
}
void initSim() {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
dawn::ShaderModule module = utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
struct Particle {

View File

@ -94,15 +94,15 @@ void init() {
initBuffers();
initTextures();
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})"
);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform sampler mySampler;
layout(set = 0, binding = 1) uniform texture2D myTexture;

View File

@ -121,7 +121,7 @@ void init() {
initBuffers();
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(set = 0, binding = 0) uniform cameraData {
mat4 view;
@ -136,10 +136,10 @@ void init() {
void main() {
f_col = col;
gl_Position = camera.proj * camera.view * modelMatrix * vec4(pos, 1.0);
})"
);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 2) in vec3 f_col;
layout(location = 0) out vec4 fragColor;
@ -148,7 +148,7 @@ void init() {
})");
dawn::ShaderModule fsReflectionModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 2) in vec3 f_col;
layout(location = 0) out vec4 fragColor;

View File

@ -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 {};
}

View File

@ -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));
}

View File

@ -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)];
}

View File

@ -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")) {

View File

@ -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:

View File

@ -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)

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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]) {

View File

@ -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 =

View File

@ -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;

View File

@ -60,7 +60,7 @@ namespace dawn_native { namespace metal {
}
const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(
dawn::ShaderStage stage) const {
ShaderStage stage) const {
return mIndexInfo[stage];
}

View File

@ -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()) {

View File

@ -40,7 +40,7 @@ namespace dawn_native { namespace metal {
}
};
MetalFunctionData GetFunction(const char* functionName,
dawn::ShaderStage functionStage,
ShaderStage functionStage,
const PipelineLayout* layout) const;
private:

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -66,7 +66,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
)";
dawn::ShaderModule module =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, shader);
utils::CreateShaderModule(device, utils::ShaderStage::Compute, shader);
dawn::ComputePipelineDescriptor cpDesc;
cpDesc.layout = pl;
@ -98,7 +98,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (set = 0, binding = 0) uniform vertexUniformBuffer {
mat2 transform;
@ -106,10 +106,10 @@ TEST_P(BindGroupTests, ReusedUBO) {
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
})"
);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout (set = 0, binding = 1) uniform fragmentUniformBuffer {
vec4 color;
@ -117,8 +117,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = color;
})"
);
})");
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device,
@ -183,7 +182,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (set = 0, binding = 0) uniform vertexUniformBuffer {
mat2 transform;
@ -191,18 +190,17 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
})"
);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout (set = 0, binding = 1) uniform sampler samp;
layout (set = 0, binding = 2) uniform texture2D tex;
layout (location = 0) out vec4 fragColor;
void main() {
fragColor = texture(sampler2D(tex, samp), gl_FragCoord.xy);
})"
);
})");
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device,
@ -301,7 +299,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (set = 0, binding = 0) uniform vertexUniformBuffer1 {
mat2 transform1;
@ -315,7 +313,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout (set = 0, binding = 1) uniform fragmentUniformBuffer1 {
vec4 color1;
@ -396,7 +394,7 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets)
{
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
@ -404,7 +402,7 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets)
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout (std140, set = 0, binding = 0) uniform fragmentUniformBuffer1 {
vec4 color1;

View File

@ -37,7 +37,7 @@ class ClipSpaceTest : public DawnTest {
gl_Position = vec4(pos[gl_VertexIndex], 1.0);
})";
pipelineDescriptor.cVertexStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs);
const char* fs =
R"(#version 450
@ -46,7 +46,7 @@ class ClipSpaceTest : public DawnTest {
fragColor = vec4(1.0, 0.0, 0.0, 1.0);
})";
pipelineDescriptor.cFragmentStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fs);
pipelineDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::LessEqual;
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState;

View File

@ -29,7 +29,7 @@ class ColorStateTest : public DawnTest {
void SetUp() override {
DawnTest::SetUp();
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(3.f, -1.f), vec2(-1.f, 3.f));
@ -56,7 +56,7 @@ class ColorStateTest : public DawnTest {
// attachment. basePipeline has no blending
void SetupSingleSourcePipelines(dawn::ColorStateDescriptor colorStateDescriptor) {
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec4 color;
@ -772,7 +772,8 @@ TEST_P(ColorStateTest, IndependentColorState) {
utils::ComboRenderPassDescriptor renderPass({renderTargetViews[0], renderTargetViews[1],
renderTargetViews[2], renderTargetViews[3]});
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec4 color0;
@ -882,7 +883,8 @@ TEST_P(ColorStateTest, IndependentColorState) {
// Test that the default blend color is correctly set at the beginning of every subpass
TEST_P(ColorStateTest, DefaultBlendColor) {
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec4 color;
@ -1005,7 +1007,8 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
// persisted and prevented a render pass loadOp from fully clearing the output
// attachment.
TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec4 color;

View File

@ -145,7 +145,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location=0) out vec2 texCoord;
void main() {
@ -158,7 +158,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
texCoord = gl_Position.xy / 2.0f + vec2(0.5f);
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform sampler sampler0;
layout(set = 0, binding = 1) uniform texture2D texture0;

View File

@ -35,7 +35,7 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
});
// Set up shader and pipeline
auto module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, shader);
auto module = utils::CreateShaderModule(device, utils::ShaderStage::Compute, shader);
auto pl = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor csDesc;

View File

@ -53,7 +53,7 @@ void ComputeIndirectTests::BasicTest(std::initializer_list<uint32_t> bufferList,
// Set up shader and pipeline
dawn::ShaderModule module =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, shaderSource);
utils::CreateShaderModule(device, utils::ShaderStage::Compute, shaderSource);
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor csDesc;

View File

@ -32,7 +32,7 @@ void ComputeSharedMemoryTests::BasicTest(const char* shader) {
});
// Set up shader and pipeline
auto module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, shader);
auto module = utils::CreateShaderModule(device, utils::ShaderStage::Compute, shader);
auto pl = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor csDesc;

View File

@ -37,7 +37,7 @@ class CullingTest : public DawnTest {
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
})";
pipelineDescriptor.cVertexStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs);
// gl_FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
// RGBA8 format for the back buffer. So (gl_FragCoord.xy - vec2(0.5)) / 255 in shader code
@ -49,7 +49,7 @@ class CullingTest : public DawnTest {
fragColor = vec4((gl_FragCoord.xy - vec2(0.5)) / 255, 0.0, 1.0);
})";
pipelineDescriptor.cFragmentStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fs);
// Set culling mode and front face according to the parameters
pipelineDescriptor.cRasterizationState.frontFace = frontFace;

View File

@ -54,7 +54,7 @@ class DepthStencilStateTest : public DawnTest {
depthTextureView = depthTexture.CreateDefaultView();
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec3 color;
@ -69,7 +69,7 @@ class DepthStencilStateTest : public DawnTest {
}
)");
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec3 color;

View File

@ -27,7 +27,7 @@ class DestroyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@ -35,7 +35,7 @@ class DestroyTest : public DawnTest {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -27,7 +27,7 @@ class DrawIndexedIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@ -35,7 +35,7 @@ class DrawIndexedIndirectTest : public DawnTest {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -27,20 +27,20 @@ class DrawIndexedTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})"
);
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;

View File

@ -27,7 +27,7 @@ class DrawIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@ -35,7 +35,7 @@ class DrawIndirectTest : public DawnTest {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -27,7 +27,7 @@ class DrawTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@ -35,7 +35,7 @@ class DrawTest : public DawnTest {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -65,7 +65,7 @@ class DynamicBufferOffsetTests : public DawnTest {
dawn::RenderPipeline CreateRenderPipeline() {
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, -1.0f));
@ -73,7 +73,7 @@ class DynamicBufferOffsetTests : public DawnTest {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(std140, set = 0, binding = 0) uniform uBuffer {
uvec2 value;
@ -100,7 +100,7 @@ class DynamicBufferOffsetTests : public DawnTest {
dawn::ComputePipeline CreateComputePipeline() {
dawn::ShaderModule csModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(std140, set = 0, binding = 0) uniform UniformBuffer {

View File

@ -268,7 +268,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
// The simplest texture sampling pipeline.
dawn::RenderPipeline pipeline;
{
dawn::ShaderModule vs = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vs =
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (location = 0) out vec2 o_texCoord;
void main() {
@ -289,7 +290,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
}
)");
dawn::ShaderModule fs =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform sampler sampler0;
layout(set = 0, binding = 1) uniform texture2D texture0;

View File

@ -31,22 +31,21 @@ class IndexFormatTest : public DawnTest {
utils::BasicRenderPass renderPass;
dawn::RenderPipeline MakeTestPipeline(dawn::IndexFormat format) {
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})"
);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})"
);
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;

View File

@ -198,11 +198,10 @@ class MultisampledRenderingTest : public DawnTest {
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
})";
pipelineDescriptor.cVertexStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs);
pipelineDescriptor.cFragmentStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fs);
mBindGroupLayout = utils::MakeBindGroupLayout(
device, {

View File

@ -59,21 +59,21 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
// Test that ShaderModules are correctly deduplicated.
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule module = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
dawn::ShaderModule sameModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
dawn::ShaderModule otherModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
@ -86,19 +86,19 @@ TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
// Test that ComputePipeline are correctly deduplicated wrt. their ShaderModule
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
dawn::ShaderModule module = utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
void main() {
int i = 0;
})");
dawn::ShaderModule sameModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
void main() {
int i = 0;
})");
dawn::ShaderModule otherModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
void main() {
})");
@ -144,7 +144,7 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
dawn::PipelineStageDescriptor stageDesc;
stageDesc.entryPoint = "main";
stageDesc.module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
stageDesc.module = utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
void main() {
int i = 0;
@ -181,12 +181,12 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device);
desc.cVertexStage.module = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
desc.cVertexStage.module = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0);
})");
desc.cFragmentStage.module = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
desc.cFragmentStage.module = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
void main() {
})");
@ -206,18 +206,19 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule module = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0);
})");
dawn::ShaderModule sameModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule sameModule =
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0);
})");
dawn::ShaderModule otherModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(1.0);
@ -227,7 +228,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device);
desc.cFragmentStage.module = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
desc.cFragmentStage.module = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
void main() {
})");
@ -247,17 +248,17 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule module = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
void main() {
})");
dawn::ShaderModule sameModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
void main() {
})");
dawn::ShaderModule otherModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
void main() {
int i = 0;
@ -267,7 +268,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device);
desc.cVertexStage.module = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
desc.cVertexStage.module = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0);

View File

@ -150,7 +150,7 @@ class PrimitiveTopologyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@ -158,7 +158,7 @@ class PrimitiveTopologyTest : public DawnTest {
gl_PointSize = 1.0;
})");
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -26,8 +26,8 @@ class DrawQuad {
DrawQuad() {}
DrawQuad(dawn::Device device, const char* vsSource, const char* fsSource)
: device(device) {
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vsSource);
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fsSource);
vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vsSource);
fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fsSource);
pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
}

View File

@ -27,7 +27,7 @@ protected:
// Shaders to draw a bottom-left triangle in blue.
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](
@ -36,7 +36,7 @@ protected:
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -50,7 +50,7 @@ protected:
auto pipelineLayout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
auto vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
auto vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[6] = vec2[6](vec2(-2.f, -2.f),
@ -62,7 +62,7 @@ protected:
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
}
)");
auto fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
auto fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform sampler sampler0;
layout(set = 0, binding = 1) uniform texture2D texture0;

View File

@ -20,7 +20,8 @@
class ScissorTest: public DawnTest {
protected:
dawn::RenderPipeline CreateQuadPipeline(dawn::TextureFormat format) {
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
const vec2 pos[6] = vec2[6](
vec2(-1.0f, -1.0f), vec2(-1.0f, 1.0f), vec2(1.0f, -1.0f),
@ -30,7 +31,8 @@ class ScissorTest: public DawnTest {
gl_Position = vec4(pos[gl_VertexIndex], 0.5, 1.0);
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -185,7 +185,7 @@ class TextureFormatTest : public DawnTest {
utils::ComboRenderPipelineDescriptor desc(device);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](
@ -225,7 +225,7 @@ class TextureFormatTest : public DawnTest {
fsSource << "}";
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fsSource.str().c_str());
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fsSource.str().c_str());
desc.cVertexStage.module = vsModule;
desc.cFragmentStage.module = fsModule;

View File

@ -47,7 +47,7 @@ namespace {
}
dawn::ShaderModule CreateDefaultVertexShaderModule(dawn::Device device) {
return utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
return utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (location = 0) out vec2 o_texCoord;
void main() {
@ -165,7 +165,7 @@ protected:
});
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fragmentShader);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fragmentShader);
utils::ComboRenderPipelineDescriptor textureDescriptor(device);
textureDescriptor.cVertexStage.module = mVSModule;
@ -503,7 +503,7 @@ class TextureViewRenderingTest : public DawnTest {
}
)";
dawn::ShaderModule oneColorFsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, oneColorFragmentShader);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, oneColorFragmentShader);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.cVertexStage.module = vsModule;

View File

@ -65,7 +65,7 @@ class TextureZeroInitTest : public DawnTest {
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
})";
pipelineDescriptor.cVertexStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs);
const char* fs =
R"(#version 450
@ -74,7 +74,7 @@ class TextureZeroInitTest : public DawnTest {
fragColor = vec4(1.0, 0.0, 0.0, 1.0);
})";
pipelineDescriptor.cFragmentStage.module =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, fs);
pipelineDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Equal;
pipelineDescriptor.cDepthStencilState.stencilFront.compare = dawn::CompareFunction::Equal;

View File

@ -341,10 +341,10 @@ class VertexFormatTest : public DawnTest {
vs << "}\n";
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs.str().c_str());
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) in vec4 color;
layout(location = 0) out vec4 fragColor;

View File

@ -117,9 +117,9 @@ class VertexInputTest : public DawnTest {
vs << "}\n";
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs.str().c_str());
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) in vec4 color;
layout(location = 0) out vec4 fragColor;

View File

@ -23,14 +23,15 @@ class ViewportOrientationTests : public DawnTest {};
TEST_P(ViewportOrientationTests, OriginAt0x0) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f);
gl_PointSize = 1.0;
})");
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -20,9 +20,9 @@ using namespace dawn_native;
// Tests for StageBit
TEST(PerStage, StageBit) {
ASSERT_EQ(StageBit(dawn::ShaderStage::Vertex), dawn::ShaderStageBit::Vertex);
ASSERT_EQ(StageBit(dawn::ShaderStage::Fragment), dawn::ShaderStageBit::Fragment);
ASSERT_EQ(StageBit(dawn::ShaderStage::Compute), dawn::ShaderStageBit::Compute);
ASSERT_EQ(StageBit(ShaderStage::Vertex), dawn::ShaderStageBit::Vertex);
ASSERT_EQ(StageBit(ShaderStage::Fragment), dawn::ShaderStageBit::Fragment);
ASSERT_EQ(StageBit(ShaderStage::Compute), dawn::ShaderStageBit::Compute);
}
// Basic test for the PerStage container
@ -30,9 +30,9 @@ TEST(PerStage, PerStage) {
PerStage<int> data;
// Store data using dawn::ShaderStage
data[dawn::ShaderStage::Vertex] = 42;
data[dawn::ShaderStage::Fragment] = 3;
data[dawn::ShaderStage::Compute] = -1;
data[ShaderStage::Vertex] = 42;
data[ShaderStage::Fragment] = 3;
data[ShaderStage::Compute] = -1;
// Load it using dawn::ShaderStageBit
ASSERT_EQ(data[dawn::ShaderStageBit::Vertex], 42);
@ -43,9 +43,9 @@ TEST(PerStage, PerStage) {
// Test IterateStages with kAllStages
TEST(PerStage, IterateAllStages) {
PerStage<int> counts;
counts[dawn::ShaderStage::Vertex] = 0;
counts[dawn::ShaderStage::Fragment] = 0;
counts[dawn::ShaderStage::Compute] = 0;
counts[ShaderStage::Vertex] = 0;
counts[ShaderStage::Fragment] = 0;
counts[ShaderStage::Compute] = 0;
for (auto stage : IterateStages(kAllStages)) {
counts[stage] ++;
@ -59,9 +59,9 @@ TEST(PerStage, IterateAllStages) {
// Test IterateStages with one stage
TEST(PerStage, IterateOneStage) {
PerStage<int> counts;
counts[dawn::ShaderStage::Vertex] = 0;
counts[dawn::ShaderStage::Fragment] = 0;
counts[dawn::ShaderStage::Compute] = 0;
counts[ShaderStage::Vertex] = 0;
counts[ShaderStage::Fragment] = 0;
counts[ShaderStage::Compute] = 0;
for (auto stage : IterateStages(dawn::ShaderStageBit::Fragment)) {
counts[stage] ++;
@ -75,9 +75,9 @@ TEST(PerStage, IterateOneStage) {
// Test IterateStages with no stage
TEST(PerStage, IterateNoStages) {
PerStage<int> counts;
counts[dawn::ShaderStage::Vertex] = 0;
counts[dawn::ShaderStage::Fragment] = 0;
counts[dawn::ShaderStage::Compute] = 0;
counts[ShaderStage::Vertex] = 0;
counts[ShaderStage::Fragment] = 0;
counts[ShaderStage::Compute] = 0;
for (auto stage : IterateStages(dawn::ShaderStageBit::Fragment & dawn::ShaderStageBit::Vertex)) {
counts[stage] ++;

View File

@ -475,13 +475,13 @@ class SetBindGroupValidationTest : public ValidationTest {
dawn::RenderPipeline CreateRenderPipeline() {
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(std140, set = 0, binding = 0) uniform uBuffer {
vec2 value1;
@ -504,7 +504,7 @@ class SetBindGroupValidationTest : public ValidationTest {
dawn::ComputePipeline CreateComputePipeline() {
dawn::ShaderModule csModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
const uint kTileSize = 4;
const uint kInstances = 11;

View File

@ -23,7 +23,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
ValidationTest::SetUp();
dawn::ShaderModule computeModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
layout(local_size_x = 1) in;
void main() {

View File

@ -24,14 +24,14 @@ class DrawIndirectValidationTest : public ValidationTest {
ValidationTest::SetUp();
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0);
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -25,8 +25,7 @@ class RenderPassValidationTest : public ValidationTest {};
// Test that it is invalid to draw in a render pass with missing bind groups
TEST_F(RenderPassValidationTest, MissingBindGroup) {
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
layout (set = 0, binding = 0) uniform vertexUniformBuffer {
mat2 transform;
@ -37,7 +36,7 @@ void main() {
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout (set = 1, binding = 0) uniform fragmentUniformBuffer {
vec4 color;

View File

@ -23,14 +23,13 @@ class RenderPipelineValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
})"
);
})");
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -24,7 +24,7 @@ class VertexBufferValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
fsModule = utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
@ -64,7 +64,7 @@ class VertexBufferValidationTest : public ValidationTest {
vs << "}\n";
return utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
return utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vs.str().c_str());
}
dawn::RenderPipeline MakeRenderPipeline(const dawn::ShaderModule& vsModule,

View File

@ -23,9 +23,9 @@ class VertexInputTest : public ValidationTest {
const utils::ComboVertexInputDescriptor& state,
std::string vertexSource) {
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vertexSource.c_str());
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, vertexSource.c_str());
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {

View File

@ -28,13 +28,13 @@ namespace utils {
namespace {
shaderc_shader_kind ShadercShaderKind(dawn::ShaderStage stage) {
shaderc_shader_kind ShadercShaderKind(ShaderStage stage) {
switch (stage) {
case dawn::ShaderStage::Vertex:
case ShaderStage::Vertex:
return shaderc_glsl_vertex_shader;
case dawn::ShaderStage::Fragment:
case ShaderStage::Fragment:
return shaderc_glsl_fragment_shader;
case dawn::ShaderStage::Compute:
case ShaderStage::Compute:
return shaderc_glsl_compute_shader;
default:
UNREACHABLE();
@ -60,7 +60,7 @@ namespace utils {
} // anonymous namespace
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
dawn::ShaderStage stage,
ShaderStage stage,
const char* source) {
shaderc_shader_kind kind = ShadercShaderKind(stage);

View File

@ -26,8 +26,10 @@ namespace utils {
enum Expectation { Success, Failure };
enum class ShaderStage { Vertex, Fragment, Compute };
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
dawn::ShaderStage stage,
ShaderStage stage,
const char* source);
dawn::ShaderModule CreateShaderModuleFromASM(const dawn::Device& device, const char* source);