mirror of https://github.com/AxioDL/boo.git
Add lazyCommitTransaction and implement for Vulkan
This commit is contained in:
parent
542191fd70
commit
c7c1162bd3
|
@ -277,6 +277,9 @@ struct IGraphicsDataFactory {
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void commitTransaction(const std::function<bool(Context& ctx)>& __BooTraceArgs) = 0;
|
virtual void commitTransaction(const std::function<bool(Context& ctx)>& __BooTraceArgs) = 0;
|
||||||
|
virtual void lazyCommitTransaction(const std::function<bool(Context& ctx)>& f __BooTraceArgs) {
|
||||||
|
commitTransaction(f __BooTraceArgsUse);
|
||||||
|
}
|
||||||
virtual ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs) = 0;
|
virtual ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs) = 0;
|
||||||
virtual void setDisplayGamma(float gamma) = 0;
|
virtual void setDisplayGamma(float gamma) = 0;
|
||||||
virtual bool isTessellationSupported(uint32_t& maxPatchSizeOut) = 0;
|
virtual bool isTessellationSupported(uint32_t& maxPatchSizeOut) = 0;
|
||||||
|
|
|
@ -130,10 +130,10 @@ public:
|
||||||
friend class VulkanDataFactoryImpl;
|
friend class VulkanDataFactoryImpl;
|
||||||
VulkanDataFactory& m_parent;
|
VulkanDataFactory& m_parent;
|
||||||
boo::ObjToken<BaseGraphicsData> m_data;
|
boo::ObjToken<BaseGraphicsData> m_data;
|
||||||
Context(VulkanDataFactory& parent __BooTraceArgs);
|
|
||||||
~Context();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Context(VulkanDataFactory& parent __BooTraceArgs);
|
||||||
|
~Context();
|
||||||
Platform platform() const { return Platform::Vulkan; }
|
Platform platform() const { return Platform::Vulkan; }
|
||||||
const SystemChar* platformName() const { return _SYS_STR("Vulkan"); }
|
const SystemChar* platformName() const { return _SYS_STR("Vulkan"); }
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <glslang/Public/ShaderLang.h>
|
#include <glslang/Public/ShaderLang.h>
|
||||||
#include <StandAlone/ResourceLimits.h>
|
#include <StandAlone/ResourceLimits.h>
|
||||||
|
@ -82,6 +83,8 @@ class VulkanDataFactoryImpl final : public VulkanDataFactory, public GraphicsDat
|
||||||
VulkanDescriptorPool* m_descPoolHead = nullptr;
|
VulkanDescriptorPool* m_descPoolHead = nullptr;
|
||||||
|
|
||||||
PipelineCompileQueue<class VulkanShaderPipeline> m_pipelineQueue;
|
PipelineCompileQueue<class VulkanShaderPipeline> m_pipelineQueue;
|
||||||
|
std::optional<Context> m_lazyContext;
|
||||||
|
void flushContext(Context&);
|
||||||
|
|
||||||
float m_gamma = 1.f;
|
float m_gamma = 1.f;
|
||||||
ObjToken<IShaderPipeline> m_gammaShader;
|
ObjToken<IShaderPipeline> m_gammaShader;
|
||||||
|
@ -126,21 +129,22 @@ public:
|
||||||
VulkanDataFactoryImpl(IGraphicsContext* parent, VulkanContext* ctx);
|
VulkanDataFactoryImpl(IGraphicsContext* parent, VulkanContext* ctx);
|
||||||
~VulkanDataFactoryImpl() { assert(m_descPoolHead == nullptr && "Dangling descriptor pools detected"); }
|
~VulkanDataFactoryImpl() { assert(m_descPoolHead == nullptr && "Dangling descriptor pools detected"); }
|
||||||
|
|
||||||
Platform platform() const { return Platform::Vulkan; }
|
Platform platform() const override { return Platform::Vulkan; }
|
||||||
const SystemChar* platformName() const { return _SYS_STR("Vulkan"); }
|
const SystemChar* platformName() const override { return _SYS_STR("Vulkan"); }
|
||||||
|
|
||||||
boo::ObjToken<VulkanDescriptorPool> allocateDescriptorSets(VkDescriptorSet* out);
|
boo::ObjToken<VulkanDescriptorPool> allocateDescriptorSets(VkDescriptorSet* out);
|
||||||
|
|
||||||
void commitTransaction(const FactoryCommitFunc& __BooTraceArgs);
|
void commitTransaction(const FactoryCommitFunc& __BooTraceArgs) override;
|
||||||
|
void lazyCommitTransaction(const FactoryCommitFunc& __BooTraceArgs) override;
|
||||||
|
|
||||||
boo::ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs);
|
boo::ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs) override;
|
||||||
|
|
||||||
void setDisplayGamma(float gamma) {
|
void setDisplayGamma(float gamma) override {
|
||||||
m_gamma = gamma;
|
m_gamma = gamma;
|
||||||
UpdateGammaLUT(m_gammaLUT.get(), gamma);
|
UpdateGammaLUT(m_gammaLUT.get(), gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTessellationSupported(uint32_t& maxPatchSizeOut) {
|
bool isTessellationSupported(uint32_t& maxPatchSizeOut) override {
|
||||||
maxPatchSizeOut = 0;
|
maxPatchSizeOut = 0;
|
||||||
if (!m_ctx->m_features.tessellationShader)
|
if (!m_ctx->m_features.tessellationShader)
|
||||||
return false;
|
return false;
|
||||||
|
@ -148,11 +152,11 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitUntilShadersReady() {
|
void waitUntilShadersReady() override {
|
||||||
m_pipelineQueue.waitUntilReady();
|
m_pipelineQueue.waitUntilReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool areShadersReady() {
|
bool areShadersReady() override {
|
||||||
return m_pipelineQueue.isReady();
|
return m_pipelineQueue.isReady();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3791,10 +3795,28 @@ boo::ObjToken<IShaderDataBinding> VulkanDataFactory::Context::newShaderDataBindi
|
||||||
|
|
||||||
void VulkanDataFactoryImpl::commitTransaction(
|
void VulkanDataFactoryImpl::commitTransaction(
|
||||||
const std::function<bool(IGraphicsDataFactory::Context&)>& trans __BooTraceArgs) {
|
const std::function<bool(IGraphicsDataFactory::Context&)>& trans __BooTraceArgs) {
|
||||||
Context ctx(*this __BooTraceArgsUse);
|
|
||||||
if (!trans(ctx))
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
Context ctx(*this __BooTraceArgsUse);
|
||||||
|
if (!trans(ctx)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_lazyContext) {
|
||||||
|
flushContext(*m_lazyContext);
|
||||||
|
m_lazyContext.reset();
|
||||||
|
}
|
||||||
|
flushContext(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VulkanDataFactoryImpl::lazyCommitTransaction(
|
||||||
|
const std::function<bool(IGraphicsDataFactory::Context&)>& trans __BooTraceArgs) {
|
||||||
|
|
||||||
|
if (!m_lazyContext) {
|
||||||
|
m_lazyContext.emplace(*this __BooTraceArgsUse);
|
||||||
|
}
|
||||||
|
trans(*m_lazyContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VulkanDataFactoryImpl::flushContext(Context& ctx) {
|
||||||
VulkanData* data = ctx.m_data.cast<VulkanData>();
|
VulkanData* data = ctx.m_data.cast<VulkanData>();
|
||||||
|
|
||||||
/* Start asynchronous shader compiles */
|
/* Start asynchronous shader compiles */
|
||||||
|
|
Loading…
Reference in New Issue