QRhiTextureRenderTargetDescription Class
렌더 타겟의 색상과 깊이, 또는 깊이/스텐실 어태치먼트를 설명합니다. 더 보기...
| 헤더: | #include <rhi/qrhi.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) |
| qmake: | QT += gui-private |
| 다음부터: | Qt 6.6부터 |
공개 함수
| QRhiTextureRenderTargetDescription() | |
| QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment) | |
| QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer) | |
| QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture) | |
| const QRhiColorAttachment * | cbeginColorAttachments() const |
| const QRhiColorAttachment * | cendColorAttachments() const |
| const QRhiColorAttachment * | colorAttachmentAt(qsizetype index) const |
| qsizetype | colorAttachmentCount() const |
(since 6.12) int | depthLayer() const |
(since 6.8) QRhiTexture * | depthResolveTexture() const |
| QRhiRenderBuffer * | depthStencilBuffer() const |
| QRhiTexture * | depthTexture() const |
| void | setColorAttachments(std::initializer_list<QRhiColorAttachment> list) |
| void | setColorAttachments(InputIterator first, InputIterator last) |
(since 6.12) void | setDepthLayer(int depthLayer) |
(since 6.8) void | setDepthResolveTexture(QRhiTexture *tex) |
| void | setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) |
| void | setDepthTexture(QRhiTexture *texture) |
(since 6.9) void | setShadingRateMap(QRhiShadingRateMap *map) |
(since 6.9) QRhiShadingRateMap * | shadingRateMap() const |
상세 설명
텍스처 렌더 타깃은 색상 어태치먼트로 0개 이상의 텍스처를, 결합된 깊이/스텐실 버퍼로 0개 또는 1개의 렌더 버퍼를, 또는 깊이 버퍼로 0개 또는 1개의 텍스처를 가집니다.
참고: ` depthStencilBuffer()`와 ` depthTexture()`를 동시에 설정할 수 없습니다(동시에 null이 아닐 수 없음).
QRhiTextureRenderTarget 와 함께 사용하는 몇 가지 사용 예제를 살펴보겠습니다.
생성자 덕분에 텍스처를 대상으로 지정하는 것(깊이/스텐실 버퍼 없음)은 간단합니다:
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(256, 256), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ texture }));다음 코드는 텍스처의 밉 레벨 #2를 대상으로 설정된 텍스처 렌더 타겟을 생성합니다:
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget | QRhiTexture::MipMapped);
texture->create();
QRhiColorAttachment colorAtt(texture);
colorAtt.setLevel(2);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ colorAtt });또 다른 예제로, 이번에는 깊이 텍스처로 렌더링하는 경우입니다:
QRhiTexture *shadowMap = rhi->newTexture(QRhiTexture::D32F, QSize(1024, 1024), 1, QRhiTexture::RenderTarget);
shadowMap->create();
QRhiTextureRenderTargetDescription rtDesc;
rtDesc.setDepthTexture(shadowMap);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget(rtDesc);매우 흔한 사례로, 색상 어태치먼트로 텍스처를 사용하고 깊이/스텐실 테스트를 활성화하기 위해 렌더 버퍼를 깊이/스텐실 버퍼로 사용하는 경우입니다:
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiRenderBuffer *depthStencil = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512));
depthStencil->create();
QRhiTextureRenderTargetDescription rtDesc({ texture }, depthStencil);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget(rtDesc);마지막으로, 이식성 있게(즉, OpenGL ES 3.0도 지원하도록) 멀티샘플 렌더링을 활성화하려면, QRhiRenderBuffer 를 (멀티샘플) 컬러 버퍼로 사용한 다음 일반(비멀티샘플) 2D 텍스처로 변환합니다. 깊이 테스트를 활성화하려면, 동일한 샘플 수를 사용해야 하는 깊이-스텐실 버퍼도 함께 사용됩니다:
QRhiRenderBuffer *colorBuffer = rhi->newRenderBuffer(QRhiRenderBuffer::Color, QSize(512, 512), 4); // 4x MSAA
colorBuffer->create();
QRhiRenderBuffer *depthStencil = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512), 4);
depthStencil->create();
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiColorAttachment colorAtt(colorBuffer);
colorAtt.setResolveTexture(texture);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ colorAtt, depthStencil });참고: 멀티샘플 해결이 활성화된경우 , 멀티샘플 데이터는 전혀 출력되지 않을 수 있습니다. 이는 resolve 텍스처가 설정된 경우, 컬러 어태치먼트 내의 멀티샘플 텍스처를 이후 셰이더에서 샘플링(또는 기타 용도)에 사용해서는 안 된다는 것을 의미합니다. 멀티샘플 컬러 버퍼는 단순히 중간 저장소일 뿐이며, 일부 GPU 아키텍처에서는 데이터가 전혀 다시 기록되지 않기 때문입니다. 자세한 내용은 PreserveColorContents 를 참조하십시오.
참고: setDepthStencilBuffer()가 아닌 setDepthTexture()를 사용할때 , 이후 깊이(스텐실) 데이터가 필요하지 않다면 QRhiTextureRenderTarget 에 DoNotStoreDepthStencilContents 플래그를 설정하십시오. 이렇게 하면 기본 3D API에 깊이/스텐실 데이터를 버려도 된다는 것을 알릴 수 있으며, 타일형 GPU 아키텍처에서 성능이 향상될 수 있습니다. 깊이-스텐실 버퍼가 QRhiRenderBuffer 인 경우(그리고 멀티샘플 컬러 텍스처의 경우에도, 앞의 참고 사항 참조) 이는 암시적으로 적용되지만, 깊이(스텐실) QRhiTexture 인 경우에는 해당 의도를 명시적으로 선언해야 합니다. 기본적으로 QRhi 는 해당 데이터가 필요하다고 가정합니다(예: 깊이 텍스처가 이후 셰이더에서 샘플링됨).
참고: 이는 호환성 보장이 제한된 RHI API입니다. 자세한 내용은 QRhi 를 참조하십시오.
QRhiColorAttachment 및 QRhiTextureRenderTarget도 참조하십시오 .
멤버 함수 문서
[constexpr noexcept default] QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription()
빈 텍스처 렌더 타겟 설명을 생성합니다.
QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment)
colorAttachment 로 정의된 하나의 첨부 파일을 포함하는 텍스처 렌더 타깃 설명을 생성합니다.
QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer)
colorAttachment 로 정의된 색상 어태치먼트와 depthStencilBuffer 로 정의된 깊이/스텐실 어태치먼트, 총 두 개의 어태치먼트를 포함하는 텍스처 렌더 타겟 설명을 생성합니다.
QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture)
colorAttachment 로 정의된 색상 어태치먼트와 depthTexture 로 정의된 깊이 어태치먼트, 총 두 개의 어태치먼트를 포함하는 텍스처 렌더 타겟 설명을 생성합니다.
참고: depthTexture 는 QRhiTexture::D16 또는 QRhiTexture::D32F 와 같은 적절한 형식을 가져야 합니다.
const QRhiColorAttachment *QRhiTextureRenderTargetDescription::cbeginColorAttachments() const
첨부 파일 목록의 첫 번째 항목을 가리키는 const 이터레이터를 반환합니다.
const QRhiColorAttachment *QRhiTextureRenderTargetDescription::cendColorAttachments() const
첨부 목록의 마지막 항목 바로 다음을 가리키는 const 이터레이터를 반환합니다.
const QRhiColorAttachment *QRhiTextureRenderTargetDescription::colorAttachmentAt(qsizetype index) const
지정된 index 위치에 있는 색상 첨부 파일을 반환합니다.
qsizetype QRhiTextureRenderTargetDescription::colorAttachmentCount() const
현재 설정된 색상 첨부 파일의 개수를 반환합니다.
[since 6.12] int QRhiTextureRenderTargetDescription::depthLayer() const
깊이/스텐실 어태치먼트에 사용될 배열 슬라이스 인덱스를 반환하며, 기본값은 -1입니다.
이 함수는 Qt 6.12에서 도입되었습니다.
setDepthLayer() 및 setDepthTexture()도 참조하십시오 .
[since 6.8] QRhiTexture *QRhiTextureRenderTargetDescription::depthResolveTexture() const
멀티샘플 깊이(또는 깊이-스텐실) 텍스처(또는 텍스처 배열)가 해결되는 텍스처를 반환합니다. 해당 텍스처가 없는 경우(가장 일반적인 경우)에는 ` nullptr `를 반환합니다.
이 함수는 Qt 6.8에서 도입되었습니다.
setDepthResolveTexture(), QRhiColorAttachment::resolveTexture(), depthTexture()도 참조하십시오 .
QRhiRenderBuffer *QRhiTextureRenderTargetDescription::depthStencilBuffer() const
깊이-스텐실 버퍼로 사용된 렌더 버퍼를 반환하거나, 설정된 것이 없는 경우 ` nullptr `를 반환합니다.
setDepthStencilBuffer()도 참조하십시오 .
QRhiTexture *QRhiTextureRenderTargetDescription::depthTexture() const
현재 참조 중인 깊이 텍스처를 반환하며, 설정된 것이 없으면 ` nullptr `를 반환합니다.
setDepthTexture()도 참조하십시오 .
void QRhiTextureRenderTargetDescription::setColorAttachments(std::initializer_list<QRhiColorAttachment> list)
색상 첨부 파일의 색상 구성 요소( list )를 설정합니다.
template <typename InputIterator> void QRhiTextureRenderTargetDescription::setColorAttachments(InputIterator first, InputIterator last)
first 및 last 반복자를 통해 색상 첨부 파일 목록을 설정합니다.
[since 6.12] void QRhiTextureRenderTargetDescription::setDepthLayer(int depthLayer)
깊이/스텐실 어태치먼트에 사용될 배열 슬라이스 인덱스를 설정합니다.
특정 레이어를 대상으로 하지 않으려면 -1(기본값)을 전달합니다. 0 이상의 값으로 설정하면, 렌더 타겟은 깊이 텍스처의 정확히 해당 레이어(슬라이스)를 대상으로 하는 뷰를 부착합니다. 이는 setDepthTexture()를 통해 2D 배열 깊이 텍스처가 제공된 경우에만 유효하며, 그렇지 않으면 해당 값은 무시됩니다.
값은 깊이 텍스처의 배열 크기 범위 내에 있어야 하며, 범위를 벗어난 인덱스를 전달하면 정의되지 않은 동작이 발생합니다. 인덱스는 텍스처 생성 시 지정된 배열 범위에 관계없이 기본 텍스처를 기준으로 절대적인 값입니다.
depthLayer 를 지정하면 깊이 어태치먼트에 대한 레이어드/멀티뷰 렌더링이 비활성화됩니다.
이 함수는 Qt 6.12에서 도입되었습니다.
depthLayer() 및 setDepthTexture()도 참조하십시오 .
[since 6.8] void QRhiTextureRenderTargetDescription::setDepthResolveTexture(QRhiTexture *tex)
tex 를 통해 깊이(또는 깊이-스텐실) 해상도 텍스처를 설정합니다.
tex setDepthTexture()를 통해 설정된 텍스처와 형식이 일치하는 2D 텍스처 또는 2D 텍스처 배열이어야 합니다.
참고: 깊이(또는 깊이-스텐실) 데이터의해결은 런타임 시점에 QRhi::ResolveDepthStencil 기능이 지원된다고 보고된 경우에만 작동합니다. 깊이-스텐실 해결에 대한 지원은 모든 그래픽 API에서 보편적으로 제공되는 것은 아닙니다. 따라서 깊이-스텐실 해결의 무조건적인 가용성을 전제로 한 설계는 이식성이 없으므로 피해야 합니다.
참고: 특히 OpenGL ES의 경우 추가적인 제한사항으로 , 깊이 해결 텍스처를 설정하는 기능은 ` setDepthTexture()`와 함께 사용할 때만 작동할 수 있으며, ` setDepthStencilBuffer()`와는 함께 사용할 수 없습니다.
이 함수는 Qt 6.8에서 도입되었습니다.
depthResolveTexture(), QRhiColorAttachment::setResolveTexture(), setDepthTexture()도 참조하십시오 .
void QRhiTextureRenderTargetDescription::setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer)
뎁스-스텐실용 renderBuffer 를 설정합니다. 필수 사항은 아닙니다. 예를 들어, 이 렌더 타겟의 모든 렌더 패스에서 그래픽 파이프라인 내에 뎁스 테스트/쓰기 또는 스텐실 관련 기능이 사용되지 않는 경우, 이 값을 nullptr 로 설정해 둘 수 있습니다.
참고: depthStencilBuffer()과 depthTexture()을 동시에 설정할 수 없습니다(동시에 null이 아닐 수 없음).
2D QRhiTexture 대신 QRhiRenderBuffer 를 깊이 또는 깊이/스텐실 버퍼로 사용하는 것은 매우 일반적이며, 애플리케이션에 권장되는 접근 방식입니다. QRhiTexture 를 사용하는 경우, 깊이 데이터에 나중에 액세스해야 하는 경우(예: 셰이더에서 샘플링)나 multiview rendering 가 관련된 경우(이때 깊이 텍스처는 텍스처 배열이어야 함)에는 setDepthTexture()가 관련됩니다.
depthStencilBuffer() 및 setDepthTexture()도 참조하십시오 .
void QRhiTextureRenderTargetDescription::setDepthTexture(QRhiTexture *texture)
뎁스-스텐실용 texture 를 설정합니다. 이는 setDepthStencilBuffer()의 대안으로, QRhiRenderBuffer 대신 적절한 유형(예: QRhiTexture::D32F)의 QRhiTexture 를 제공합니다.
참고: depthStencilBuffer()과 depthTexture()을 동시에 설정할 수 없습니다(동시에 null이 아닐 수 없음).
texture texture는 2D 텍스처이거나(텍스처 배열이 지원되는 경우) 2D 텍스처 배열일 수 있습니다. 텍스처 배열을 지정하는 것은 특히 multiview rendering 와 관련이 있습니다.
참고: texture 가 QRhiTexture::D24S8 와 같이 스텐실 구성 요소를 갖는 형식인경우 , 이 형식은 스텐실 버퍼 역할도 수행합니다.
depthTexture() 및 setDepthStencilBuffer()도 참조하십시오 .
[since 6.9] void QRhiTextureRenderTargetDescription::setShadingRateMap(QRhiShadingRateMap *map)
지정된 QRhiShadingRateMap map 와 연결됩니다. 이 기능은 QRhi::VariableRateShadingMap 기능이 지원된다고 보고된 경우에만 작동합니다.
QRhiCommandBuffer::setShadingRate()도 호출된 경우, 각 타일에 대해 두 셰이딩 속도 중 더 높은 쪽이 사용됩니다. 현재 콤바이너의 동작을 제어할 수 있는 방법은 없습니다.
참고: 렌더 타겟이 이미 구축된 상태(create()가 성공적으로 호출된경우 )에서 셰이딩 레이트 맵을 설정하면, 새로운 QRhiRenderPassDescriptor 가 필요하므로 재구축이 필요합니다. setRenderPassDescriptor()를 다시 호출한 후(렌더 패스 외부에서), create()를 호출하여 재구축하십시오. 이는 그래픽 파이프라인 등 다른 요소에도 연쇄적인 영향을 미칩니다. 해당 요소들도 새로운 QRhiRenderPassDescriptor 와 연결된 후 재구축되어야 합니다. 이에 대한 대처 방법은 QRhiRenderPassDescriptor::serializedFormat()을 참조하십시오. 또한 QRhiGraphicsPipeline::UsesShadingRate 플래그도 설정해야 합니다.
이 함수는 Qt 6.9에서 도입되었습니다.
shadingRateMap()도 참조하십시오 .
[since 6.9] QRhiShadingRateMap *QRhiTextureRenderTargetDescription::shadingRateMap() const
현재 설정된 ‘ QRhiShadingRateMap ’ 값을 반환합니다. 기본값은 ‘ nullptr ’입니다.
이 함수는 Qt 6.9에서 도입되었습니다.
setShadingRateMap()도 참조하십시오 .
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.