Adding the sub samples control

This commit is contained in:
Sam Gateau 2019-02-03 21:31:19 -08:00
parent b970c31c5c
commit d0a044120a
2 changed files with 24 additions and 3 deletions

View file

@ -144,18 +144,22 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
task.addJob<Blit>("Blit", framebuffer); task.addJob<Blit>("Blit", framebuffer);
} }
void PrepareFramebuffer::configure(const PrepareFramebuffer::Config& config) {
_numSamples = config.getNumSamples();
}
void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) { void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w); glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w);
// Resizing framebuffers instead of re-building them seems to cause issues with threaded rendering // Resizing framebuffers instead of re-building them seems to cause issues with threaded rendering
if (_framebuffer && _framebuffer->getSize() != frameSize) { if (_framebuffer && (_framebuffer->getSize() != frameSize || _framebuffer->getNumSamples() != _numSamples)) {
_framebuffer.reset(); _framebuffer.reset();
} }
if (!_framebuffer) { if (!_framebuffer) {
_framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("forward")); _framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("forward"));
int numSamples = 8; int numSamples = _numSamples;
auto colorFormat = gpu::Element::COLOR_SRGBA_32; auto colorFormat = gpu::Element::COLOR_SRGBA_32;
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);

View file

@ -27,16 +27,33 @@ public:
void build(JobModel& task, const render::Varying& input, render::Varying& output); void build(JobModel& task, const render::Varying& input, render::Varying& output);
}; };
class PrepareFramebufferConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(int numSamples WRITE setNumSamples READ getNumSamples NOTIFY dirty)
public:
int getNumSamples() const { return numSamples; }
void setNumSamples(int num) { numSamples = num; emit dirty(); }
signals:
void dirty();
protected:
int numSamples{ 8 };
};
class PrepareFramebuffer { class PrepareFramebuffer {
public: public:
using Inputs = gpu::FramebufferPointer; using Inputs = gpu::FramebufferPointer;
using JobModel = render::Job::ModelO<PrepareFramebuffer, Inputs>; using Config = PrepareFramebufferConfig;
using JobModel = render::Job::ModelO<PrepareFramebuffer, Inputs, Config>;
void configure(const Config& config);
void run(const render::RenderContextPointer& renderContext, void run(const render::RenderContextPointer& renderContext,
gpu::FramebufferPointer& framebuffer); gpu::FramebufferPointer& framebuffer);
private: private:
gpu::FramebufferPointer _framebuffer; gpu::FramebufferPointer _framebuffer;
int _numSamples { 8 };
}; };
class PrepareForward { class PrepareForward {