19 _id = globalRenderTargetId++;
27 assert(_device !=
nullptr &&
"Failed to obtain the device, colorBuffer nor depthBuffer store it.");
30 int maxSamples = _device->maxSamples();
31 _samples = std::min(options.
samples, maxSamples);
44 auto format = _depthBuffer->format();
57 spdlog::warn(
"Incorrect depthBuffer format. Must be pc.PIXELFORMAT_DEPTH or pc.PIXELFORMAT_DEPTHSTENCIL");
62 _depth = options.
depth;
68 assert((_colorBuffers.empty() || _colorBuffers.size() == 1) &&
69 "When constructing RenderTarget and options.colorBuffers is used, options.colorBuffer must not be used.");
71 if (_colorBuffers.empty() || _colorBuffers.size() == 1) {
82 if (_name.empty() && _colorBuffer) {
83 _name = _colorBuffer->name();
85 if (_name.empty() && _depthBuffer) {
86 _name = _depthBuffer->name();
93 _flipY = options.
flipY;
96 if (_mipLevel > 0 && _depth) {
97 spdlog::error(
"Rendering to a mipLevel is not supported when render target uses a depth buffer. Ignoring mipLevel " +
98 std::to_string(_mipLevel) +
" for render target " + _name);
107 spdlog::trace(
"Alloc: Id " + std::to_string(_id) +
" " + _name +
": " +
108 std::to_string(
width()) +
"x" + std::to_string(
height()) +
109 " [samples: " + std::to_string(_samples) +
"]" +
110 (!_colorBuffers.empty() ?
"[MRT: " + std::to_string(_colorBuffers.size()) +
"]" :
"") +
111 (_colorBuffer ?
"[Color]" :
"") +
112 (_depth ?
"[Depth]" :
"") +
113 (_stencil ?
"[Stencil]" :
"") +
114 "[Face:" + std::to_string(_face) +
"]");
188 if (!_colorBuffers.empty()) {
189 int width = _colorBuffers[0]->width();
190 int height = _colorBuffers[0]->height();
191 bool cubemap = _colorBuffers[0]->isCubemap();
192 bool volume = _colorBuffers[0]->isVolume();
194 for (
size_t i = 1; i < _colorBuffers.size(); i++) {
196 assert(
colorBuffer->width() ==
width &&
"All render target color buffers must have the same width");
198 "All render target color buffers must have the same height");
200 "All render target color buffers must have the same cubemap setting");
202 "All render target color buffers must have the same volume setting");
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
GraphicsDevice * device() const
static uint32_t calcLevelDimension(uint32_t dimension, uint32_t mipLevel)