Metal: Remove vertexState in the parameter of TranslateToMSL
This patch removes the parameter "vertexState" from TranslateToMSL and ShaderModule::CreateFunction as we have already been able to get the vertex states from the RenderPipelineBase object. BUG=dawn:529 Change-Id: I2971438bfd5e0f3fbea900e1f06c1b33349571da Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64140 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
020d69905e
commit
24cad6e2c3
|
@ -1035,30 +1035,36 @@ namespace dawn_native {
|
||||||
return std::move(output.program);
|
return std::move(output.program);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddVertexPullingTransformConfig(const VertexState& vertexState,
|
void AddVertexPullingTransformConfig(const RenderPipelineBase& renderPipeline,
|
||||||
const std::string& entryPoint,
|
const std::string& entryPoint,
|
||||||
BindGroupIndex pullingBufferBindingSet,
|
BindGroupIndex pullingBufferBindingSet,
|
||||||
tint::transform::DataMap* transformInputs) {
|
tint::transform::DataMap* transformInputs) {
|
||||||
tint::transform::VertexPulling::Config cfg;
|
tint::transform::VertexPulling::Config cfg;
|
||||||
cfg.entry_point_name = entryPoint;
|
cfg.entry_point_name = entryPoint;
|
||||||
cfg.pulling_group = static_cast<uint32_t>(pullingBufferBindingSet);
|
cfg.pulling_group = static_cast<uint32_t>(pullingBufferBindingSet);
|
||||||
for (uint32_t i = 0; i < vertexState.bufferCount; ++i) {
|
|
||||||
const auto& vertexBuffer = vertexState.buffers[i];
|
|
||||||
tint::transform::VertexBufferLayoutDescriptor layout;
|
|
||||||
layout.array_stride = vertexBuffer.arrayStride;
|
|
||||||
layout.step_mode = ToTintVertexStepMode(vertexBuffer.stepMode);
|
|
||||||
|
|
||||||
for (uint32_t j = 0; j < vertexBuffer.attributeCount; ++j) {
|
const auto& vertexBufferSlotUsed = renderPipeline.GetVertexBufferSlotsUsed();
|
||||||
const auto& attribute = vertexBuffer.attributes[j];
|
cfg.vertex_state.resize(renderPipeline.GetVertexBufferCount());
|
||||||
tint::transform::VertexAttributeDescriptor attr;
|
for (uint8_t vertexBufferSlot = 0;
|
||||||
attr.format = ToTintVertexFormat(attribute.format);
|
vertexBufferSlot < static_cast<uint8_t>(cfg.vertex_state.size()); ++vertexBufferSlot) {
|
||||||
attr.offset = attribute.offset;
|
if (vertexBufferSlotUsed[static_cast<VertexBufferSlot>(vertexBufferSlot)]) {
|
||||||
attr.shader_location = attribute.shaderLocation;
|
const auto& vertexBuffer =
|
||||||
|
renderPipeline.GetVertexBuffer(static_cast<VertexBufferSlot>(vertexBufferSlot));
|
||||||
layout.attributes.push_back(std::move(attr));
|
cfg.vertex_state[vertexBufferSlot].array_stride = vertexBuffer.arrayStride;
|
||||||
|
cfg.vertex_state[vertexBufferSlot].step_mode =
|
||||||
|
ToTintVertexStepMode(vertexBuffer.stepMode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cfg.vertex_state.push_back(std::move(layout));
|
for (VertexAttributeLocation location :
|
||||||
|
IterateBitSet(renderPipeline.GetAttributeLocationsUsed())) {
|
||||||
|
const auto& attribute = renderPipeline.GetAttribute(location);
|
||||||
|
tint::transform::VertexAttributeDescriptor attr;
|
||||||
|
attr.format = ToTintVertexFormat(attribute.format);
|
||||||
|
attr.offset = attribute.offset;
|
||||||
|
attr.shader_location = static_cast<uint32_t>(static_cast<uint8_t>(location));
|
||||||
|
ASSERT(vertexBufferSlotUsed[attribute.vertexBufferSlot]);
|
||||||
|
uint8_t vertexBufferSlot = static_cast<uint8_t>(attribute.vertexBufferSlot);
|
||||||
|
cfg.vertex_state[vertexBufferSlot].attributes.push_back(attr);
|
||||||
}
|
}
|
||||||
transformInputs->Add<tint::transform::VertexPulling::Config>(cfg);
|
transformInputs->Add<tint::transform::VertexPulling::Config>(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace dawn_native {
|
||||||
OwnedCompilationMessages* messages);
|
OwnedCompilationMessages* messages);
|
||||||
|
|
||||||
/// Creates and adds the tint::transform::VertexPulling::Config to transformInputs.
|
/// Creates and adds the tint::transform::VertexPulling::Config to transformInputs.
|
||||||
void AddVertexPullingTransformConfig(const VertexState& vertexState,
|
void AddVertexPullingTransformConfig(const RenderPipelineBase& renderPipeline,
|
||||||
const std::string& entryPoint,
|
const std::string& entryPoint,
|
||||||
BindGroupIndex pullingBufferBindingSet,
|
BindGroupIndex pullingBufferBindingSet,
|
||||||
tint::transform::DataMap* transformInputs);
|
tint::transform::DataMap* transformInputs);
|
||||||
|
|
|
@ -341,17 +341,9 @@ namespace dawn_native { namespace metal {
|
||||||
ShaderModule* vertexModule = ToBackend(descriptor->vertex.module);
|
ShaderModule* vertexModule = ToBackend(descriptor->vertex.module);
|
||||||
const char* vertexEntryPoint = descriptor->vertex.entryPoint;
|
const char* vertexEntryPoint = descriptor->vertex.entryPoint;
|
||||||
ShaderModule::MetalFunctionData vertexData;
|
ShaderModule::MetalFunctionData vertexData;
|
||||||
|
|
||||||
const VertexState* vertexStatePtr = &descriptor->vertex;
|
|
||||||
VertexState vertexState;
|
|
||||||
if (vertexStatePtr == nullptr) {
|
|
||||||
vertexState = {};
|
|
||||||
vertexStatePtr = &vertexState;
|
|
||||||
}
|
|
||||||
|
|
||||||
DAWN_TRY(vertexModule->CreateFunction(vertexEntryPoint, SingleShaderStage::Vertex,
|
DAWN_TRY(vertexModule->CreateFunction(vertexEntryPoint, SingleShaderStage::Vertex,
|
||||||
ToBackend(GetLayout()), &vertexData, 0xFFFFFFFF, this,
|
ToBackend(GetLayout()), &vertexData, 0xFFFFFFFF,
|
||||||
vertexStatePtr));
|
this));
|
||||||
|
|
||||||
descriptorMTL.vertexFunction = vertexData.function.Get();
|
descriptorMTL.vertexFunction = vertexData.function.Get();
|
||||||
if (vertexData.needsStorageBufferLength) {
|
if (vertexData.needsStorageBufferLength) {
|
||||||
|
|
|
@ -43,8 +43,7 @@ namespace dawn_native { namespace metal {
|
||||||
const PipelineLayout* layout,
|
const PipelineLayout* layout,
|
||||||
MetalFunctionData* out,
|
MetalFunctionData* out,
|
||||||
uint32_t sampleMask = 0xFFFFFFFF,
|
uint32_t sampleMask = 0xFFFFFFFF,
|
||||||
const RenderPipeline* renderPipeline = nullptr,
|
const RenderPipeline* renderPipeline = nullptr);
|
||||||
const VertexState* vertexState = nullptr);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResultOrError<std::string> TranslateToMSL(const char* entryPointName,
|
ResultOrError<std::string> TranslateToMSL(const char* entryPointName,
|
||||||
|
@ -52,7 +51,6 @@ namespace dawn_native { namespace metal {
|
||||||
const PipelineLayout* layout,
|
const PipelineLayout* layout,
|
||||||
uint32_t sampleMask,
|
uint32_t sampleMask,
|
||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline,
|
||||||
const VertexState* vertexState,
|
|
||||||
std::string* remappedEntryPointName,
|
std::string* remappedEntryPointName,
|
||||||
bool* needsStorageBufferLength,
|
bool* needsStorageBufferLength,
|
||||||
bool* hasInvariantAttribute);
|
bool* hasInvariantAttribute);
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace dawn_native { namespace metal {
|
||||||
const PipelineLayout* layout,
|
const PipelineLayout* layout,
|
||||||
uint32_t sampleMask,
|
uint32_t sampleMask,
|
||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline,
|
||||||
const VertexState* vertexState,
|
|
||||||
std::string* remappedEntryPointName,
|
std::string* remappedEntryPointName,
|
||||||
bool* needsStorageBufferLength,
|
bool* needsStorageBufferLength,
|
||||||
bool* hasInvariantAttribute) {
|
bool* hasInvariantAttribute) {
|
||||||
|
@ -100,8 +99,8 @@ namespace dawn_native { namespace metal {
|
||||||
if (stage == SingleShaderStage::Vertex &&
|
if (stage == SingleShaderStage::Vertex &&
|
||||||
GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling)) {
|
GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling)) {
|
||||||
transformManager.Add<tint::transform::VertexPulling>();
|
transformManager.Add<tint::transform::VertexPulling>();
|
||||||
AddVertexPullingTransformConfig(*vertexState, entryPointName, kPullingBufferBindingSet,
|
AddVertexPullingTransformConfig(*renderPipeline, entryPointName,
|
||||||
&transformInputs);
|
kPullingBufferBindingSet, &transformInputs);
|
||||||
|
|
||||||
for (VertexBufferSlot slot :
|
for (VertexBufferSlot slot :
|
||||||
IterateBitSet(renderPipeline->GetVertexBufferSlotsUsed())) {
|
IterateBitSet(renderPipeline->GetVertexBufferSlotsUsed())) {
|
||||||
|
@ -176,15 +175,13 @@ namespace dawn_native { namespace metal {
|
||||||
const PipelineLayout* layout,
|
const PipelineLayout* layout,
|
||||||
ShaderModule::MetalFunctionData* out,
|
ShaderModule::MetalFunctionData* out,
|
||||||
uint32_t sampleMask,
|
uint32_t sampleMask,
|
||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline) {
|
||||||
const VertexState* vertexState) {
|
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
ASSERT(out);
|
ASSERT(out);
|
||||||
|
|
||||||
// Vertex stages must specify a renderPipeline and vertexState
|
// Vertex stages must specify a renderPipeline
|
||||||
if (stage == SingleShaderStage::Vertex) {
|
if (stage == SingleShaderStage::Vertex) {
|
||||||
ASSERT(renderPipeline != nullptr);
|
ASSERT(renderPipeline != nullptr);
|
||||||
ASSERT(vertexState != nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string remappedEntryPointName;
|
std::string remappedEntryPointName;
|
||||||
|
@ -192,8 +189,8 @@ namespace dawn_native { namespace metal {
|
||||||
bool hasInvariantAttribute = false;
|
bool hasInvariantAttribute = false;
|
||||||
DAWN_TRY_ASSIGN(msl,
|
DAWN_TRY_ASSIGN(msl,
|
||||||
TranslateToMSL(entryPointName, stage, layout, sampleMask, renderPipeline,
|
TranslateToMSL(entryPointName, stage, layout, sampleMask, renderPipeline,
|
||||||
vertexState, &remappedEntryPointName,
|
&remappedEntryPointName, &out->needsStorageBufferLength,
|
||||||
&out->needsStorageBufferLength, &hasInvariantAttribute));
|
&hasInvariantAttribute));
|
||||||
|
|
||||||
// Metal uses Clang to compile the shader as C++14. Disable everything in the -Wall
|
// Metal uses Clang to compile the shader as C++14. Disable everything in the -Wall
|
||||||
// category. -Wunused-variable in particular comes up a lot in generated code, and some
|
// category. -Wunused-variable in particular comes up a lot in generated code, and some
|
||||||
|
|
Loading…
Reference in New Issue