mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:34:07 +02:00
Adding the sub samples control
This commit is contained in:
parent
b970c31c5c
commit
d0a044120a
2 changed files with 24 additions and 3 deletions
|
@ -144,18 +144,22 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
|||
task.addJob<Blit>("Blit", framebuffer);
|
||||
}
|
||||
|
||||
void PrepareFramebuffer::configure(const PrepareFramebuffer::Config& config) {
|
||||
_numSamples = config.getNumSamples();
|
||||
}
|
||||
|
||||
void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
||||
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
|
||||
if (_framebuffer && _framebuffer->getSize() != frameSize) {
|
||||
if (_framebuffer && (_framebuffer->getSize() != frameSize || _framebuffer->getNumSamples() != _numSamples)) {
|
||||
_framebuffer.reset();
|
||||
}
|
||||
|
||||
if (!_framebuffer) {
|
||||
_framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("forward"));
|
||||
|
||||
int numSamples = 8;
|
||||
int numSamples = _numSamples;
|
||||
|
||||
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
|
||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
|
||||
|
|
|
@ -27,16 +27,33 @@ public:
|
|||
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 {
|
||||
public:
|
||||
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,
|
||||
gpu::FramebufferPointer& framebuffer);
|
||||
|
||||
private:
|
||||
gpu::FramebufferPointer _framebuffer;
|
||||
int _numSamples { 8 };
|
||||
};
|
||||
|
||||
class PrepareForward {
|
||||
|
|
Loading…
Reference in a new issue