15 if (_options !=
nullptr && _renderTarget !=
nullptr) {
16 if (
const auto* resizeSource = _options->resizeSource !=
nullptr ? _options->resizeSource.get() : _device->backBuffer()->getColorBuffer(0))
18 const auto width = std::floor(resizeSource->width() *
scaleX());
19 const auto height = std::floor(resizeSource->height() *
scaleY());
20 _renderTarget->resize(width, height);
28 const bool realPass = _renderTargetInitialized;
30 log(_device, _device->_renderPassIndex);
34 if (_executeEnabled) {
35 bool passReady =
true;
37 if (realPass && !_skipStart) {
38 _device->startRenderPass(
this);
39 passReady = _device->insideRenderPass();
46 if (realPass && !_skipEnd && passReady) {
47 _device->endRenderPass(
this);
53 _device->_renderPassIndex++;
58 if (_enabled != value) {
74 _renderTargetInitialized =
true;
92 if (_options->scaleX == 0.0f)
94 _options->scaleX = 1.0f;
96 if (_options->scaleY == 0.0f)
98 _options->scaleY = 1.0f;
106 _depthStencilOps = std::make_shared<DepthStencilAttachmentOps>();
110 if (_renderTarget && _renderTarget->hasDepthBuffer()) {
111 _depthStencilOps->storeDepth =
true;
115 int numColorOps = _renderTarget ? _renderTarget->colorBufferCount() : 1;
116 _colorArrayOps.clear();
117 _colorArrayOps.resize(numColorOps);
119 for (
int i = 0; i < numColorOps; i++) {
120 auto colorOps = std::make_shared<ColorAttachmentOps>();
130 if (_renderTarget && _renderTarget->hasMipmaps() && i < _renderTarget->colorBufferCount()) {
131 auto colorBuffer = _renderTarget->getColorBuffer(i);
132 if (colorBuffer && colorBuffer->mipmaps()) {
143 for (
const auto&
colorOps : _colorArrayOps) {
150 colorOps->clearValueLinear = *color;
159 if (!_depthStencilOps) {
164 _depthStencilOps->clearDepthValue = *depthValue;
166 _depthStencilOps->clearDepth = depthValue !=
nullptr;
171 if (!_depthStencilOps) {
176 _depthStencilOps->clearStencilValue = *stencilValue;
178 _depthStencilOps->clearStencil = stencilValue !=
nullptr;
183 const auto& rt = _renderTarget ==
nullptr ? nullptr :
device->backBuffer();
184 bool isBackBuffer =
false;
186 bool hasDepth =
false;
187 bool hasStencil =
false;
191 numColor = rt->colorBufferCount();
192 hasDepth = rt->hasDepthBuffer();
193 hasStencil = rt->hasStencil();
194 mipLevel = rt->mipLevel();
201 rtInfo =
" RT: " + rt->name();
205 rtInfo +=
" x " + std::to_string(numColor);
215 rtInfo +=
"[Stencil]";
217 rtInfo +=
" " + std::to_string(rt->width()) +
" x " + std::to_string(rt->height());
219 rtInfo +=
" samples: " + std::to_string(_samples);
222 rtInfo +=
" mipLevel: " + std::to_string(mipLevel);
226 std::string indexString = _skipStart ?
"++" : std::to_string(index);
231 if (!_colorArrayOps.empty()) {
232 return _colorArrayOps[0];
240 _beforePasses.push_back(renderPass);
247 _afterPasses.push_back(renderPass);
253 _beforePasses.clear();
258 _afterPasses.clear();
virtual void init(const std::shared_ptr< RenderTarget > &renderTarget=nullptr, const std::shared_ptr< RenderPassOptions > &options=nullptr)
void setClearColor(const Color *color=nullptr)
void setClearDepth(const float *depthValue=nullptr)
void allocateAttachments()
void setClearStencil(const int *stencilValue=nullptr)
std::shared_ptr< RenderTarget > renderTarget() const
virtual void frameUpdate() const
std::shared_ptr< GraphicsDevice > device() const
void addBeforePass(const std::shared_ptr< RenderPass > &renderPass)
std::shared_ptr< ColorAttachmentOps > colorOps() const
void addAfterPass(const std::shared_ptr< RenderPass > &renderPass)
void log(std::shared_ptr< GraphicsDevice > device, int index=0) const
void setEnabled(bool value)
void setOptions(const std::shared_ptr< RenderPassOptions > &value)
bool isIntegerPixelFormat(const PixelFormat format)
RGBA color with floating-point components in [0, 1].