Commit 7d0ce41d by Ben Clayton

Vulkan: Plumb the debug context down to SpirvShader

SpirvShader doesn't actually do anything with this (yet). Extracts the dull plumbing from the meat of the SpirvShader debugger implementation. Bug: b/145351270 Change-Id: I1a648d8e463c428a232f711d0cc5dd0ecf94ad1e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38914Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent a4e06ca0
......@@ -29,7 +29,8 @@ SpirvShader::SpirvShader(
InsnStore const &insns,
const vk::RenderPass *renderPass,
uint32_t subpassIndex,
bool robustBufferAccess)
bool robustBufferAccess,
const std::shared_ptr<vk::dbg::Context> &dbgctx)
: insns{ insns }
, inputs{ MAX_INTERFACE_COMPONENTS }
, outputs{ MAX_INTERFACE_COMPONENTS }
......
......@@ -50,6 +50,10 @@ class Sampler;
class RenderPass;
struct SampledImageDescriptor;
namespace dbg {
class Context;
} // namespace dbg
} // namespace vk
namespace sw {
......@@ -473,7 +477,8 @@ public:
InsnStore const &insns,
const vk::RenderPass *renderPass,
uint32_t subpassIndex,
bool robustBufferAccess);
bool robustBufferAccess,
const std::shared_ptr<vk::dbg::Context> &dbgctx);
struct Modes
{
......
......@@ -98,12 +98,14 @@ public:
rr::Routine *findInConstCache(const SamplingRoutineCache::Key &key) const;
void updateSamplingRoutineConstCache();
#ifdef ENABLE_VK_DEBUGGER
std::shared_ptr<vk::dbg::Context> getDebuggerContext() const
{
#ifdef ENABLE_VK_DEBUGGER
return debugger.context;
}
#else
return nullptr;
#endif // ENABLE_VK_DEBUGGER
}
private:
PhysicalDevice *const physicalDevice = nullptr;
......
......@@ -212,7 +212,11 @@ std::vector<uint32_t> preprocessSpirv(
return optimized;
}
std::shared_ptr<sw::SpirvShader> createShader(const vk::PipelineCache::SpirvShaderKey &key, const vk::ShaderModule *module, bool robustBufferAccess)
std::shared_ptr<sw::SpirvShader> createShader(
const vk::PipelineCache::SpirvShaderKey &key,
const vk::ShaderModule *module,
bool robustBufferAccess,
const std::shared_ptr<vk::dbg::Context> &dbgctx)
{
auto code = preprocessSpirv(key.getInsns(), key.getSpecializationInfo());
ASSERT(code.size() > 0);
......@@ -223,7 +227,7 @@ std::shared_ptr<sw::SpirvShader> createShader(const vk::PipelineCache::SpirvShad
// TODO(b/119409619): use allocator.
return std::make_shared<sw::SpirvShader>(codeSerialID, key.getPipelineStage(), key.getEntryPointName().c_str(),
code, key.getRenderPass(), key.getSubpassIndex(), robustBufferAccess);
code, key.getRenderPass(), key.getSubpassIndex(), robustBufferAccess, dbgctx);
}
std::shared_ptr<sw::ComputeProgram> createProgram(const vk::PipelineCache::ComputeProgramKey &key)
......@@ -244,6 +248,7 @@ namespace vk {
Pipeline::Pipeline(PipelineLayout const *layout, const Device *device)
: layout(layout)
, device(device)
, robustBufferAccess(device->getEnabledFeatures().robustBufferAccess)
{
}
......@@ -550,7 +555,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c
const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[key];
if(!spirvShader)
{
auto shader = createShader(key, module, robustBufferAccess);
auto shader = createShader(key, module, robustBufferAccess, device->getDebuggerContext());
setShader(pipelineStage, shader);
pipelineCache.insert(key, getShader(pipelineStage));
}
......@@ -562,7 +567,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c
}
else
{
auto shader = createShader(key, module, robustBufferAccess);
auto shader = createShader(key, module, robustBufferAccess, device->getDebuggerContext());
setShader(pipelineStage, shader);
}
}
......@@ -650,7 +655,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co
const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[shaderKey];
if(!spirvShader)
{
shader = createShader(shaderKey, module, robustBufferAccess);
shader = createShader(shaderKey, module, robustBufferAccess, device->getDebuggerContext());
pipelineCache.insert(shaderKey, shader);
}
else
......@@ -676,7 +681,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co
}
else
{
shader = createShader(shaderKey, module, robustBufferAccess);
shader = createShader(shaderKey, module, robustBufferAccess, device->getDebuggerContext());
const PipelineCache::ComputeProgramKey programKey(shader.get(), layout);
program = createProgram(programKey);
}
......
......@@ -30,6 +30,10 @@ class SpirvShader;
namespace vk {
namespace dbg {
class Context;
} // namespace dbg
class PipelineCache;
class PipelineLayout;
class ShaderModule;
......@@ -68,6 +72,7 @@ public:
protected:
PipelineLayout const *layout = nullptr;
Device const *const device;
const bool robustBufferAccess = true;
};
......@@ -75,7 +80,9 @@ protected:
class GraphicsPipeline : public Pipeline, public ObjectBase<GraphicsPipeline, VkPipeline>
{
public:
GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo, void *mem, const Device *device);
GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo,
void *mem,
const Device *device);
virtual ~GraphicsPipeline() = default;
void destroyPipeline(const VkAllocationCallbacks *pAllocator) override;
......
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