Commit ea81ab76 by Chris Forbes

Move constant specialization to SpirvShader

SPIRV-Tools' pass to do this is incomplete, and implementing the remaining pieces as a SPIRV->SPIRV transform is more work than implementing them here. Related SPIRV-Tools issues: 2585 2586 Bug: b/127454276 Test: dEQP-VK.*quantize* Change-Id: I892de80dff366fb3bc417315b5db15d850577c47 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31348Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 67cf8a92
...@@ -814,7 +814,6 @@ namespace sw ...@@ -814,7 +814,6 @@ namespace sw
template<typename F> template<typename F>
void VisitMemoryObjectInner(Type::ID id, Decorations d, uint32_t &index, uint32_t offset, F f) const; void VisitMemoryObjectInner(Type::ID id, Decorations d, uint32_t &index, uint32_t offset, F f) const;
uint32_t GetConstantInt(Object::ID id) const;
Object& CreateConstant(InsnIterator it); Object& CreateConstant(InsnIterator it);
void ProcessInterfaceVariable(Object &object); void ProcessInterfaceVariable(Object &object);
...@@ -959,6 +958,9 @@ namespace sw ...@@ -959,6 +958,9 @@ namespace sw
void GetImageDimensions(SpirvRoutine const *routine, Type const &resultTy, Object::ID imageId, Object::ID lodId, Intermediate &dst) const; void GetImageDimensions(SpirvRoutine const *routine, Type const &resultTy, Object::ID imageId, Object::ID lodId, Intermediate &dst) const;
SIMD::Pointer GetTexelAddress(SpirvRoutine const *routine, SIMD::Pointer base, GenericValue const & coordinate, Type const & imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const; SIMD::Pointer GetTexelAddress(SpirvRoutine const *routine, SIMD::Pointer base, GenericValue const & coordinate, Type const & imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const;
uint32_t GetConstScalarInt(Object::ID id) const; uint32_t GetConstScalarInt(Object::ID id) const;
void EvalSpecConstantOp(InsnIterator insn);
void EvalSpecConstantUnaryOp(InsnIterator insn);
void EvalSpecConstantBinaryOp(InsnIterator insn);
// LoadPhi loads the phi values from the alloca storage and places the // LoadPhi loads the phi values from the alloca storage and places the
// load values into the intermediate with the phi's result id. // load values into the intermediate with the phi's result id.
......
...@@ -194,9 +194,6 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -194,9 +194,6 @@ std::vector<uint32_t> preprocessSpirv(
} }
opt.RegisterPass(spvtools::CreateSetSpecConstantDefaultValuePass(specializations)); opt.RegisterPass(spvtools::CreateSetSpecConstantDefaultValuePass(specializations));
} }
// Freeze specialization constants into normal constants, and propagate through
opt.RegisterPass(spvtools::CreateFreezeSpecConstantValuePass());
opt.RegisterPass(spvtools::CreateFoldSpecConstantOpAndCompositePass());
// Basic optimization passes to primarily address glslang's love of loads & // Basic optimization passes to primarily address glslang's love of loads &
// stores. Significantly reduces time spent in LLVM passes and codegen. // stores. Significantly reduces time spent in LLVM passes and codegen.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment