Commit 24466043 by Chris Forbes

Partial support for input attachments

- Collect input attachment formats from the current subpass - Include InputAttachmentIndex in descriptor decorations - Make window-space integer coords available to fragment shader - Rework EmitImageLoad to use VkFormat rather than spirv format - Use window-space-coord-relative addressing for GetTexelPointer on spv::DimSubpassData images - Use input attachment format rather than OpTypeImage baked-in format for spv::DimSubpassData images. Bug: b/131171141 Test: dEQP-VK.renderpass*.input.* Change-Id: I15412e66516ea907d4b2ffd913a9eb1a3f8a9bb9 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29689Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 72631d34
...@@ -24,6 +24,9 @@ namespace sw ...@@ -24,6 +24,9 @@ namespace sw
void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w) void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w)
{ {
routine.windowSpacePosition[0] = x + SIMD::Int(0,1,0,1);
routine.windowSpacePosition[1] = y + SIMD::Int(0,0,1,1);
auto it = spirvShader->inputBuiltins.find(spv::BuiltInFragCoord); auto it = spirvShader->inputBuiltins.find(spv::BuiltInFragCoord);
if (it != spirvShader->inputBuiltins.end()) if (it != spirvShader->inputBuiltins.end())
{ {
......
...@@ -45,6 +45,7 @@ namespace vk ...@@ -45,6 +45,7 @@ namespace vk
class PipelineLayout; class PipelineLayout;
class ImageView; class ImageView;
class Sampler; class Sampler;
class RenderPass;
} // namespace vk } // namespace vk
namespace sw namespace sw
...@@ -474,7 +475,7 @@ namespace sw ...@@ -474,7 +475,7 @@ namespace sw
return serialID; return serialID;
} }
explicit SpirvShader(InsnStore const &insns); SpirvShader(InsnStore const &insns, vk::RenderPass *renderPass, uint32_t subpassIndex);
struct Modes struct Modes
{ {
...@@ -565,11 +566,13 @@ namespace sw ...@@ -565,11 +566,13 @@ namespace sw
{ {
int32_t DescriptorSet = -1; int32_t DescriptorSet = -1;
int32_t Binding = -1; int32_t Binding = -1;
int32_t InputAttachmentIndex = -1;
void Apply(DescriptorDecorations const &src); void Apply(DescriptorDecorations const &src);
}; };
std::unordered_map<Object::ID, DescriptorDecorations> descriptorDecorations; std::unordered_map<Object::ID, DescriptorDecorations> descriptorDecorations;
std::vector<VkFormat> inputAttachmentFormats;
struct InterfaceComponent struct InterfaceComponent
{ {
...@@ -840,7 +843,7 @@ namespace sw ...@@ -840,7 +843,7 @@ namespace sw
EmitResult EmitAtomicOp(InsnIterator insn, EmitState *state) const; EmitResult EmitAtomicOp(InsnIterator insn, EmitState *state) const;
EmitResult EmitAtomicCompareExchange(InsnIterator insn, EmitState *state) const; EmitResult EmitAtomicCompareExchange(InsnIterator insn, EmitState *state) const;
SIMD::Pointer GetTexelAddress(SIMD::Pointer base, GenericValue const & coordinate, Type const & imageType, Pointer<Byte> descriptor, int texelSize) const; SIMD::Pointer GetTexelAddress(SpirvRoutine const * routine, SIMD::Pointer base, GenericValue const & coordinate, Type const & imageType, Pointer<Byte> descriptor, int texelSize) const;
// OpcodeName() returns the name of the opcode op. // OpcodeName() returns the name of the opcode op.
// If NDEBUG is defined, then OpcodeName() will only return the numerical code. // If NDEBUG is defined, then OpcodeName() will only return the numerical code.
...@@ -896,6 +899,7 @@ namespace sw ...@@ -896,6 +899,7 @@ namespace sw
Pointer<Int> descriptorDynamicOffsets; Pointer<Int> descriptorDynamicOffsets;
Pointer<Byte> pushConstants; Pointer<Byte> pushConstants;
Int killMask = Int{0}; Int killMask = Int{0};
SIMD::Int windowSpacePosition[2];
void createVariable(SpirvShader::Object::ID id, uint32_t size) void createVariable(SpirvShader::Object::ID id, uint32_t size)
{ {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "VkPipeline.hpp" #include "VkPipeline.hpp"
#include "VkPipelineLayout.hpp" #include "VkPipelineLayout.hpp"
#include "VkShaderModule.hpp" #include "VkShaderModule.hpp"
#include "VkRenderPass.hpp"
#include "Pipeline/ComputeProgram.hpp" #include "Pipeline/ComputeProgram.hpp"
#include "Pipeline/SpirvShader.hpp" #include "Pipeline/SpirvShader.hpp"
...@@ -452,7 +453,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c ...@@ -452,7 +453,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c
// FIXME (b/119409619): use an allocator here so we can control all memory allocations // FIXME (b/119409619): use an allocator here so we can control all memory allocations
// TODO: also pass in any pipeline state which will affect shader compilation // TODO: also pass in any pipeline state which will affect shader compilation
auto spirvShader = new sw::SpirvShader{code}; auto spirvShader = new sw::SpirvShader{code, Cast(pCreateInfo->renderPass), pCreateInfo->subpass};
switch (pStage->stage) switch (pStage->stage)
{ {
...@@ -544,7 +545,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks* pAllocator, co ...@@ -544,7 +545,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks* pAllocator, co
ASSERT(shader == nullptr); ASSERT(shader == nullptr);
// FIXME(b/119409619): use allocator. // FIXME(b/119409619): use allocator.
shader = new sw::SpirvShader(code); shader = new sw::SpirvShader(code, nullptr, 0);
vk::DescriptorSet::Bindings descriptorSets; // FIXME(b/129523279): Delay code generation until invoke time. vk::DescriptorSet::Bindings descriptorSets; // FIXME(b/129523279): Delay code generation until invoke time.
sw::ComputeProgram program(shader, layout, descriptorSets); sw::ComputeProgram program(shader, layout, descriptorSets);
......
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