[spirv-writer] Cleanup capabilities code.
This CL simplifies the capabilities code in the SPIR-V builder. Bug: tint:5 Change-Id: Iff99350b2d6a2534c82ea3d47a0a9186d0dcb6ac Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22661 Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
65cd5a8e0d
commit
7615d9468c
|
@ -138,11 +138,10 @@ Builder::Builder(ast::Module* mod) : mod_(mod), scope_stack_({}) {}
|
|||
Builder::~Builder() = default;
|
||||
|
||||
bool Builder::Build() {
|
||||
push_capability(spv::Op::OpCapability, {Operand::Int(SpvCapabilityShader)});
|
||||
push_capability(SpvCapabilityShader);
|
||||
|
||||
// TODO(dneto): Stop using the Vulkan memory model. crbug.com/tint/63
|
||||
push_capability(spv::Op::OpCapability,
|
||||
{Operand::Int(SpvCapabilityVulkanMemoryModel)});
|
||||
push_capability(SpvCapabilityVulkanMemoryModel);
|
||||
push_preamble(spv::Op::OpExtension,
|
||||
{Operand::String("SPV_KHR_vulkan_memory_model")});
|
||||
|
||||
|
@ -221,6 +220,11 @@ void Builder::iterate(std::function<void(const Instruction&)> cb) const {
|
|||
}
|
||||
}
|
||||
|
||||
void Builder::push_capability(uint32_t cap) {
|
||||
capabilities_.push_back(
|
||||
Instruction{spv::Op::OpCapability, {Operand::Int(cap)}});
|
||||
}
|
||||
|
||||
uint32_t Builder::GenerateU32Literal(uint32_t val) {
|
||||
ast::type::U32Type u32;
|
||||
ast::SintLiteral lit(&u32, val);
|
||||
|
@ -1251,8 +1255,7 @@ uint32_t Builder::GenerateIntrinsic(const std::string& name,
|
|||
|
||||
if (ast::intrinsic::IsFineDerivative(name) ||
|
||||
ast::intrinsic::IsCoarseDerivative(name)) {
|
||||
push_capability(spv::Op::OpCapability,
|
||||
{Operand::Int(SpvCapabilityDerivativeControl)});
|
||||
push_capability(SpvCapabilityDerivativeControl);
|
||||
}
|
||||
|
||||
spv::Op op = spv::Op::OpNop;
|
||||
|
|
|
@ -120,11 +120,8 @@ class Builder {
|
|||
void iterate(std::function<void(const Instruction&)> cb) const;
|
||||
|
||||
/// Adds an instruction to the list of capabilities
|
||||
/// @param op the op to set
|
||||
/// @param operands the operands for the instruction
|
||||
void push_capability(spv::Op op, const std::vector<Operand>& operands) {
|
||||
capabilities_.push_back(Instruction{op, operands});
|
||||
}
|
||||
/// @param cap the capability to set
|
||||
void push_capability(uint32_t cap);
|
||||
/// @returns the capabilities
|
||||
const std::vector<Instruction>& capabilities() const { return capabilities_; }
|
||||
/// Adds an instruction to the preamble
|
||||
|
|
Loading…
Reference in New Issue