Commit c2968064 by Chris Forbes

Vulkan: Plumb bound descriptor sets down to SpirvRoutine.

Choice of tests is slightly odd -- but there are a number of tests in this group which *don't* use the derivative instructions (glslang is smart enough to not emit them when the expression is known to be uniform). Bug: b/126330097 Test: dEQP-VK.glsl.derivate.* Test: dEQP-VK.ubo.* Change-Id: I8864149104f2ea9b62c75ceae59da4ff8adebc32 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26548Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 26672437
...@@ -156,6 +156,11 @@ namespace sw ...@@ -156,6 +156,11 @@ namespace sw
void Context::init() void Context::init()
{ {
for(int i = 0; i < vk::MAX_BOUND_DESCRIPTOR_SETS; i++)
{
descriptorSets[i] = nullptr;
}
// Set vertex streams to null stream // Set vertex streams to null stream
for(int i = 0; i < MAX_VERTEX_INPUTS; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
......
...@@ -22,8 +22,11 @@ ...@@ -22,8 +22,11 @@
#include "Vertex.hpp" #include "Vertex.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include <Vulkan/VkConfig.h>
namespace vk namespace vk
{ {
class DescriptorSet;
class ImageView; class ImageView;
class PipelineLayout; class PipelineLayout;
} // namespace vk } // namespace vk
...@@ -182,6 +185,7 @@ namespace sw ...@@ -182,6 +185,7 @@ namespace sw
int colorWriteActive(int index); int colorWriteActive(int index);
bool colorUsed(); bool colorUsed();
vk::DescriptorSet *descriptorSets[vk::MAX_BOUND_DESCRIPTOR_SETS];
Stream input[MAX_VERTEX_INPUTS]; Stream input[MAX_VERTEX_INPUTS];
void *indexBuffer; void *indexBuffer;
......
...@@ -28,7 +28,7 @@ namespace sw ...@@ -28,7 +28,7 @@ namespace sw
QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader); QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader);
virtual ~QuadRasterizer(); virtual ~QuadRasterizer();
void generate(); virtual void generate();
protected: protected:
Pointer<Byte> constants; Pointer<Byte> constants;
......
...@@ -310,6 +310,11 @@ namespace sw ...@@ -310,6 +310,11 @@ namespace sw
draw->setupPrimitives = setupPrimitives; draw->setupPrimitives = setupPrimitives;
draw->setupState = setupState; draw->setupState = setupState;
for(int i = 0; i < vk::MAX_BOUND_DESCRIPTOR_SETS; i++)
{
data->descriptorSets[i] = context->descriptorSets[i];
}
for(int i = 0; i < MAX_VERTEX_INPUTS; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
data->input[i] = context->input[i].buffer; data->input[i] = context->input[i].buffer;
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#include <list> #include <list>
namespace vk
{
class DescriptorSet;
}
namespace sw namespace sw
{ {
class Clipper; class Clipper;
...@@ -115,6 +120,8 @@ namespace sw ...@@ -115,6 +120,8 @@ namespace sw
{ {
const Constants *constants; const Constants *constants;
vk::DescriptorSet *descriptorSets[vk::MAX_BOUND_DESCRIPTOR_SETS];
const void *input[MAX_VERTEX_INPUTS]; const void *input[MAX_VERTEX_INPUTS];
unsigned int stride[MAX_VERTEX_INPUTS]; unsigned int stride[MAX_VERTEX_INPUTS];
Texture mipmap[TOTAL_IMAGE_UNITS]; Texture mipmap[TOTAL_IMAGE_UNITS];
......
...@@ -48,7 +48,7 @@ struct LibX11exports ...@@ -48,7 +48,7 @@ struct LibX11exports
int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event); int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event);
}; };
#undef Bool #undef Bool // b/127920555
class LibX11 class LibX11
{ {
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
#include "Device/QuadRasterizer.hpp" #include "Device/QuadRasterizer.hpp"
#include "Device/Primitive.hpp" #include "Device/Primitive.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
#ifdef Bool
#undef Bool // b/127920555
#endif
namespace sw namespace sw
{ {
...@@ -49,6 +54,18 @@ namespace sw ...@@ -49,6 +54,18 @@ namespace sw
{ {
} }
void PixelRoutine::generate()
{
Pointer<Pointer<Byte>> descriptorSets = Pointer<Pointer<Byte>>(data + OFFSET(DrawData, descriptorSets));
auto numDescriptorSets = routine.pipelineLayout->getNumDescriptorSets();
for(unsigned int i = 0; i < numDescriptorSets; i++)
{
routine.descriptorSets[i] = descriptorSets[i];
}
QuadRasterizer::generate();
}
void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y)
{ {
#if PERF_PROFILE #if PERF_PROFILE
......
...@@ -31,6 +31,8 @@ namespace sw ...@@ -31,6 +31,8 @@ namespace sw
virtual ~PixelRoutine(); virtual ~PixelRoutine();
void generate() override;
protected: protected:
Float4 z[4]; // Multisampled z Float4 z[4]; // Multisampled z
Float4 w; // Used as is Float4 w; // Used as is
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "System/Half.hpp" #include "System/Half.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
namespace sw namespace sw
{ {
VertexProgram::VertexProgram( VertexProgram::VertexProgram(
...@@ -45,6 +47,13 @@ namespace sw ...@@ -45,6 +47,13 @@ namespace sw
} }
routine.pushConstants = data + OFFSET(DrawData, pushConstants); routine.pushConstants = data + OFFSET(DrawData, pushConstants);
Pointer<Pointer<Byte>> descriptorSets = Pointer<Pointer<Byte>>(data + OFFSET(DrawData, descriptorSets));
auto numDescriptorSets = routine.pipelineLayout->getNumDescriptorSets();
for(unsigned int i = 0; i < numDescriptorSets; i++)
{
routine.descriptorSets[i] = descriptorSets[i];
}
} }
VertexProgram::~VertexProgram() VertexProgram::~VertexProgram()
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string> #include <string>
#undef Bool #undef Bool // b/127920555
#if !defined(NDEBUG) && (REACTOR_LLVM_VERSION >= 7) #if !defined(NDEBUG) && (REACTOR_LLVM_VERSION >= 7)
#define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH() #define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH()
......
...@@ -247,6 +247,12 @@ struct Draw : public CommandBuffer::Command ...@@ -247,6 +247,12 @@ struct Draw : public CommandBuffer::Command
sw::Context context = pipeline->getContext(); sw::Context context = pipeline->getContext();
executionState.bindVertexInputs(context, firstVertex); executionState.bindVertexInputs(context, firstVertex);
const auto& boundDescriptorSets = executionState.boundDescriptorSets[VK_PIPELINE_BIND_POINT_GRAPHICS];
for(int i = 0; i < vk::MAX_BOUND_DESCRIPTOR_SETS; i++)
{
context.descriptorSets[i] = reinterpret_cast<vk::DescriptorSet*>(boundDescriptorSets[i]);
}
context.pushConstants = executionState.pushConstants; context.pushConstants = executionState.pushConstants;
executionState.renderer->setContext(context); executionState.renderer->setContext(context);
...@@ -286,6 +292,12 @@ struct DrawIndexed : public CommandBuffer::Command ...@@ -286,6 +292,12 @@ struct DrawIndexed : public CommandBuffer::Command
sw::Context context = pipeline->getContext(); sw::Context context = pipeline->getContext();
executionState.bindVertexInputs(context, vertexOffset); executionState.bindVertexInputs(context, vertexOffset);
const auto& boundDescriptorSets = executionState.boundDescriptorSets[VK_PIPELINE_BIND_POINT_GRAPHICS];
for(int i = 0; i < vk::MAX_BOUND_DESCRIPTOR_SETS; i++)
{
context.descriptorSets[i] = reinterpret_cast<vk::DescriptorSet*>(boundDescriptorSets[i]);
}
context.pushConstants = executionState.pushConstants; context.pushConstants = executionState.pushConstants;
context.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer( context.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer(
......
...@@ -48,7 +48,7 @@ struct LibX11exports ...@@ -48,7 +48,7 @@ struct LibX11exports
int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event); int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event);
}; };
#undef Bool #undef Bool // b/127920555
class LibX11 class LibX11
{ {
......
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