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
void Context::init()
{
for(int i = 0; i < vk::MAX_BOUND_DESCRIPTOR_SETS; i++)
{
descriptorSets[i] = nullptr;
}
// Set vertex streams to null stream
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
......
......@@ -22,8 +22,11 @@
#include "Vertex.hpp"
#include "System/Types.hpp"
#include <Vulkan/VkConfig.h>
namespace vk
{
class DescriptorSet;
class ImageView;
class PipelineLayout;
} // namespace vk
......@@ -182,6 +185,7 @@ namespace sw
int colorWriteActive(int index);
bool colorUsed();
vk::DescriptorSet *descriptorSets[vk::MAX_BOUND_DESCRIPTOR_SETS];
Stream input[MAX_VERTEX_INPUTS];
void *indexBuffer;
......
......@@ -28,7 +28,7 @@ namespace sw
QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader);
virtual ~QuadRasterizer();
void generate();
virtual void generate();
protected:
Pointer<Byte> constants;
......
......@@ -310,6 +310,11 @@ namespace sw
draw->setupPrimitives = setupPrimitives;
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++)
{
data->input[i] = context->input[i].buffer;
......
......@@ -26,6 +26,11 @@
#include <list>
namespace vk
{
class DescriptorSet;
}
namespace sw
{
class Clipper;
......@@ -115,6 +120,8 @@ namespace sw
{
const Constants *constants;
vk::DescriptorSet *descriptorSets[vk::MAX_BOUND_DESCRIPTOR_SETS];
const void *input[MAX_VERTEX_INPUTS];
unsigned int stride[MAX_VERTEX_INPUTS];
Texture mipmap[TOTAL_IMAGE_UNITS];
......
......@@ -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);
};
#undef Bool
#undef Bool // b/127920555
class LibX11
{
......
......@@ -20,6 +20,11 @@
#include "Device/QuadRasterizer.hpp"
#include "Device/Primitive.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
#ifdef Bool
#undef Bool // b/127920555
#endif
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)
{
#if PERF_PROFILE
......
......@@ -31,6 +31,8 @@ namespace sw
virtual ~PixelRoutine();
void generate() override;
protected:
Float4 z[4]; // Multisampled z
Float4 w; // Used as is
......
......@@ -20,6 +20,8 @@
#include "System/Half.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
namespace sw
{
VertexProgram::VertexProgram(
......@@ -45,6 +47,13 @@ namespace sw
}
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()
......
......@@ -24,7 +24,7 @@
#include <string>
#undef Bool
#undef Bool // b/127920555
#if !defined(NDEBUG) && (REACTOR_LLVM_VERSION >= 7)
#define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH()
......
......@@ -247,6 +247,12 @@ struct Draw : public CommandBuffer::Command
sw::Context context = pipeline->getContext();
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;
executionState.renderer->setContext(context);
......@@ -286,6 +292,12 @@ struct DrawIndexed : public CommandBuffer::Command
sw::Context context = pipeline->getContext();
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.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer(
......
......@@ -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);
};
#undef Bool
#undef Bool // b/127920555
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