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( ...@@ -29,7 +29,8 @@ SpirvShader::SpirvShader(
InsnStore const &insns, InsnStore const &insns,
const vk::RenderPass *renderPass, const vk::RenderPass *renderPass,
uint32_t subpassIndex, uint32_t subpassIndex,
bool robustBufferAccess) bool robustBufferAccess,
const std::shared_ptr<vk::dbg::Context> &dbgctx)
: insns{ insns } : insns{ insns }
, inputs{ MAX_INTERFACE_COMPONENTS } , inputs{ MAX_INTERFACE_COMPONENTS }
, outputs{ MAX_INTERFACE_COMPONENTS } , outputs{ MAX_INTERFACE_COMPONENTS }
......
...@@ -50,6 +50,10 @@ class Sampler; ...@@ -50,6 +50,10 @@ class Sampler;
class RenderPass; class RenderPass;
struct SampledImageDescriptor; struct SampledImageDescriptor;
namespace dbg {
class Context;
} // namespace dbg
} // namespace vk } // namespace vk
namespace sw { namespace sw {
...@@ -473,7 +477,8 @@ public: ...@@ -473,7 +477,8 @@ public:
InsnStore const &insns, InsnStore const &insns,
const vk::RenderPass *renderPass, const vk::RenderPass *renderPass,
uint32_t subpassIndex, uint32_t subpassIndex,
bool robustBufferAccess); bool robustBufferAccess,
const std::shared_ptr<vk::dbg::Context> &dbgctx);
struct Modes struct Modes
{ {
......
...@@ -98,12 +98,14 @@ public: ...@@ -98,12 +98,14 @@ public:
rr::Routine *findInConstCache(const SamplingRoutineCache::Key &key) const; rr::Routine *findInConstCache(const SamplingRoutineCache::Key &key) const;
void updateSamplingRoutineConstCache(); void updateSamplingRoutineConstCache();
#ifdef ENABLE_VK_DEBUGGER
std::shared_ptr<vk::dbg::Context> getDebuggerContext() const std::shared_ptr<vk::dbg::Context> getDebuggerContext() const
{ {
#ifdef ENABLE_VK_DEBUGGER
return debugger.context; return debugger.context;
} #else
return nullptr;
#endif // ENABLE_VK_DEBUGGER #endif // ENABLE_VK_DEBUGGER
}
private: private:
PhysicalDevice *const physicalDevice = nullptr; PhysicalDevice *const physicalDevice = nullptr;
......
...@@ -212,7 +212,11 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -212,7 +212,11 @@ std::vector<uint32_t> preprocessSpirv(
return optimized; 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()); auto code = preprocessSpirv(key.getInsns(), key.getSpecializationInfo());
ASSERT(code.size() > 0); ASSERT(code.size() > 0);
...@@ -223,7 +227,7 @@ std::shared_ptr<sw::SpirvShader> createShader(const vk::PipelineCache::SpirvShad ...@@ -223,7 +227,7 @@ std::shared_ptr<sw::SpirvShader> createShader(const vk::PipelineCache::SpirvShad
// TODO(b/119409619): use allocator. // TODO(b/119409619): use allocator.
return std::make_shared<sw::SpirvShader>(codeSerialID, key.getPipelineStage(), key.getEntryPointName().c_str(), 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) std::shared_ptr<sw::ComputeProgram> createProgram(const vk::PipelineCache::ComputeProgramKey &key)
...@@ -244,6 +248,7 @@ namespace vk { ...@@ -244,6 +248,7 @@ namespace vk {
Pipeline::Pipeline(PipelineLayout const *layout, const Device *device) Pipeline::Pipeline(PipelineLayout const *layout, const Device *device)
: layout(layout) : layout(layout)
, device(device)
, robustBufferAccess(device->getEnabledFeatures().robustBufferAccess) , robustBufferAccess(device->getEnabledFeatures().robustBufferAccess)
{ {
} }
...@@ -550,7 +555,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c ...@@ -550,7 +555,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c
const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[key]; const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[key];
if(!spirvShader) if(!spirvShader)
{ {
auto shader = createShader(key, module, robustBufferAccess); auto shader = createShader(key, module, robustBufferAccess, device->getDebuggerContext());
setShader(pipelineStage, shader); setShader(pipelineStage, shader);
pipelineCache.insert(key, getShader(pipelineStage)); pipelineCache.insert(key, getShader(pipelineStage));
} }
...@@ -562,7 +567,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c ...@@ -562,7 +567,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks *pAllocator, c
} }
else else
{ {
auto shader = createShader(key, module, robustBufferAccess); auto shader = createShader(key, module, robustBufferAccess, device->getDebuggerContext());
setShader(pipelineStage, shader); setShader(pipelineStage, shader);
} }
} }
...@@ -650,7 +655,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co ...@@ -650,7 +655,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co
const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[shaderKey]; const std::shared_ptr<sw::SpirvShader> *spirvShader = pipelineCache[shaderKey];
if(!spirvShader) if(!spirvShader)
{ {
shader = createShader(shaderKey, module, robustBufferAccess); shader = createShader(shaderKey, module, robustBufferAccess, device->getDebuggerContext());
pipelineCache.insert(shaderKey, shader); pipelineCache.insert(shaderKey, shader);
} }
else else
...@@ -676,7 +681,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co ...@@ -676,7 +681,7 @@ void ComputePipeline::compileShaders(const VkAllocationCallbacks *pAllocator, co
} }
else else
{ {
shader = createShader(shaderKey, module, robustBufferAccess); shader = createShader(shaderKey, module, robustBufferAccess, device->getDebuggerContext());
const PipelineCache::ComputeProgramKey programKey(shader.get(), layout); const PipelineCache::ComputeProgramKey programKey(shader.get(), layout);
program = createProgram(programKey); program = createProgram(programKey);
} }
......
...@@ -30,6 +30,10 @@ class SpirvShader; ...@@ -30,6 +30,10 @@ class SpirvShader;
namespace vk { namespace vk {
namespace dbg {
class Context;
} // namespace dbg
class PipelineCache; class PipelineCache;
class PipelineLayout; class PipelineLayout;
class ShaderModule; class ShaderModule;
...@@ -68,6 +72,7 @@ public: ...@@ -68,6 +72,7 @@ public:
protected: protected:
PipelineLayout const *layout = nullptr; PipelineLayout const *layout = nullptr;
Device const *const device;
const bool robustBufferAccess = true; const bool robustBufferAccess = true;
}; };
...@@ -75,7 +80,9 @@ protected: ...@@ -75,7 +80,9 @@ protected:
class GraphicsPipeline : public Pipeline, public ObjectBase<GraphicsPipeline, VkPipeline> class GraphicsPipeline : public Pipeline, public ObjectBase<GraphicsPipeline, VkPipeline>
{ {
public: public:
GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo, void *mem, const Device *device); GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo,
void *mem,
const Device *device);
virtual ~GraphicsPipeline() = default; virtual ~GraphicsPipeline() = default;
void destroyPipeline(const VkAllocationCallbacks *pAllocator) override; 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