bool Framebuffer::assignDepthStencilBuffer(const TexturePointer& texture, const Format& format, uint32 subresource) { if (isSwapchain()) { return false; } Q_ASSERT(!texture || TextureUsageType::RENDERBUFFER == texture->getUsageType()); // Check for the compatibility of size if (texture) { if (!validateTargetCompatibility(*texture)) { return false; } if (texture->source().empty()) { texture->setSource(_name + "::depthStencil"); } } ++_depthStamp; updateSize(texture); // assign the new one _depthStencilBuffer = TextureView(texture, subresource, format); return true; }
// Render buffers int Framebuffer::setRenderBuffer(uint32 slot, const TexturePointer& texture, uint32 subresource) { if (isSwapchain()) { return -1; } Q_ASSERT(!texture || TextureUsageType::RENDERBUFFER == texture->getUsageType()); // Check for the slot if (slot >= getMaxNumRenderBuffers()) { return -1; } // Check for the compatibility of size if (texture) { if (!validateTargetCompatibility(*texture, subresource)) { return -1; } if (texture->source().empty()) { texture->setSource(_name + "::color::" + std::to_string(slot)); } } ++_colorStamps[slot]; updateSize(texture); // assign the new one _renderBuffers[slot] = TextureView(texture, subresource); // update the mask int mask = (1<<slot); _bufferMask = (_bufferMask & ~(mask)); if (texture) { _bufferMask |= mask; } return slot; }