![]() |
Qt 6.x
The Qt SDK
|
#include <qrhivulkan_p.h>
Classes | |
struct | UsageState |
Public Member Functions | |
QVkTexture (QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags) | |
~QVkTexture () | |
void | destroy () override |
Releases (or requests deferred releasing of) the underlying native graphics resources. | |
bool | create () override |
Creates the corresponding native graphics resources. | |
bool | createFrom (NativeTexture src) override |
Similar to create(), except that no new native textures are created. | |
NativeTexture | nativeTexture () override |
void | setNativeLayout (int layout) override |
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API directly needs special care when it comes to image layouts. | |
bool | prepareCreate (QSize *adjustedSize=nullptr) |
bool | finishCreate () |
VkImageView | imageViewForLevel (int level) |
![]() | |
QRhiResource::Type | resourceType () const override |
Format | format () const |
void | setFormat (Format fmt) |
Sets the requested texture format to fmt. | |
QSize | pixelSize () const |
void | setPixelSize (const QSize &sz) |
Sets the texture size, specified in pixels, to sz. | |
int | depth () const |
void | setDepth (int depth) |
Sets the depth for a 3D texture. | |
int | arraySize () const |
void | setArraySize (int arraySize) |
Sets the texture arraySize. | |
int | arrayRangeStart () const |
int | arrayRangeLength () const |
void | setArrayRange (int startIndex, int count) |
Normally all array layers are exposed and it is up to the shader to select the layer via the third coordinate passed to the {texture()} GLSL function when sampling the sampler2DArray . | |
Flags | flags () const |
void | setFlags (Flags f) |
Sets the texture flags to f. | |
int | sampleCount () const |
void | setSampleCount (int s) |
Sets the sample count to s. | |
virtual bool | create ()=0 |
Creates the corresponding native graphics resources. | |
virtual NativeTexture | nativeTexture () |
virtual bool | createFrom (NativeTexture src) |
Similar to create(), except that no new native textures are created. | |
virtual void | setNativeLayout (int layout) |
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API directly needs special care when it comes to image layouts. | |
![]() | |
virtual | ~QRhiResource () |
Destructor. | |
virtual Type | resourceType () const =0 |
virtual void | destroy ()=0 |
Releases (or requests deferred releasing of) the underlying native graphics resources. | |
void | deleteLater () |
When called without a frame being recorded, this function is equivalent to deleting the object. | |
QByteArray | name () const |
void | setName (const QByteArray &name) |
Sets a name for the object. | |
quint64 | globalResourceId () const |
QRhi * | rhi () const |
Public Attributes | |
VkImage | image = VK_NULL_HANDLE |
VkImageView | imageView = VK_NULL_HANDLE |
QVkAlloc | imageAlloc = nullptr |
VkBuffer | stagingBuffers [QVK_FRAMES_IN_FLIGHT] |
QVkAlloc | stagingAllocations [QVK_FRAMES_IN_FLIGHT] |
VkImageView | perLevelImageViews [QRhi::MAX_MIP_LEVELS] |
bool | owns = true |
UsageState | usageState |
VkFormat | vkformat |
uint | mipLevelCount = 0 |
VkSampleCountFlagBits | samples |
int | lastActiveFrameSlot = -1 |
uint | generation = 0 |
Friends | |
class | QRhiVulkan |
Definition at line 93 of file qrhivulkan_p.h.
QVkTexture::QVkTexture | ( | QRhiImplementation * | rhi, |
Format | format, | ||
const QSize & | pixelSize, | ||
int | depth, | ||
int | arraySize, | ||
int | sampleCount, | ||
Flags | flags | ||
) |
Definition at line 6058 of file qrhivulkan.cpp.
References i, QRhi::MAX_MIP_LEVELS, perLevelImageViews, QVK_FRAMES_IN_FLIGHT, stagingAllocations, and stagingBuffers.
QVkTexture::~QVkTexture | ( | ) |
Definition at line 6070 of file qrhivulkan.cpp.
References destroy().
|
overridevirtual |
Creates the corresponding native graphics resources.
If there are already resources present due to an earlier create() with no corresponding destroy(), then destroy() is called implicitly first.
true
when successful, false
when a graphics operation failed. Regardless of the return value, calling destroy() is always safe. Implements QRhiTexture.
Definition at line 6240 of file qrhivulkan.cpp.
References allocation, QRhiTexture::CubeMap, finishCreate(), imageAlloc, isDepthTextureFormat(), QRhiTexture::m_arraySize, QRhiTexture::m_depth, QRhiTexture::m_flags, QRhiTexture::m_format, QRhiResource::m_objectName, mipLevelCount, QRhiTexture::OneDimensional, owns, prepareCreate(), qMax(), QRHI_RES_RHI, qWarning, QRhiTexture::RenderTarget, samples, QRhiTexture::TextureArray, QRhiTexture::ThreeDimensional, toVmaAllocator(), QRhiTexture::UsedAsTransferSource, QRhiTexture::UsedWithGenerateMips, QRhiTexture::UsedWithLoadStore, and vkformat.
Referenced by QVkRenderBuffer::create().
|
overridevirtual |
Similar to create(), except that no new native textures are created.
Instead, the native texture resources specified by src is used.
This allows importing an existing native texture object (which must belong to the same device or sharing context, depending on the graphics API) from an external graphics engine.
The opposite of this operation, exposing a QRhiTexture-created native texture object to a foreign engine, is possible via nativeTexture().
Reimplemented from QRhiTexture.
Definition at line 6321 of file qrhivulkan.cpp.
References finishCreate(), QVkTexture::UsageState::layout, owns, prepareCreate(), QRHI_RES_RHI, and usageState.
|
overridevirtual |
Releases (or requests deferred releasing of) the underlying native graphics resources.
Safe to call multiple times, subsequent invocations will be a no-op then.
Once destroy() is called, the QRhiResource instance can be reused, by calling create()
again. That will then result in creating new native graphics resources underneath.
The QRhiResource destructor also performs the same task, so calling this function is not necessary before deleting a QRhiResource.
Implements QRhiResource.
Definition at line 6075 of file qrhivulkan.cpp.
References e, i, image, imageAlloc, imageView, lastActiveFrameSlot, QRhi::MAX_MIP_LEVELS, owns, perLevelImageViews, QRHI_RES_RHI, QVK_FRAMES_IN_FLIGHT, stagingAllocations, stagingBuffers, and QRhiVulkan::DeferredReleaseEntry::Texture.
Referenced by ~QVkTexture(), QVkRenderBuffer::destroy(), and prepareCreate().
bool QVkTexture::finishCreate | ( | ) |
Definition at line 6196 of file qrhivulkan.cpp.
References aspectMaskForTextureFormat(), QRhiTexture::CubeMap, generation, image, imageView, lastActiveFrameSlot, QRhiTexture::m_arrayRangeLength, QRhiTexture::m_arrayRangeStart, QRhiTexture::m_arraySize, QRhiTexture::m_flags, QRhiTexture::m_format, mipLevelCount, QRhiTexture::OneDimensional, qMax(), QRHI_RES_RHI, qWarning, QRhiTexture::TextureArray, QRhiTexture::ThreeDimensional, and vkformat.
Referenced by create(), and createFrom().
VkImageView QVkTexture::imageViewForLevel | ( | int | level | ) |
Definition at line 6353 of file qrhivulkan.cpp.
References aspectMaskForTextureFormat(), QRhiTexture::CubeMap, image, QRhiTexture::m_arraySize, QRhiTexture::m_flags, QRhiTexture::m_format, mipLevelCount, QRhiTexture::OneDimensional, perLevelImageViews, Q_ASSERT, qMax(), QRHI_RES_RHI, qWarning, QRhiTexture::TextureArray, QRhiTexture::ThreeDimensional, and vkformat.
Referenced by QRhiVulkan::updateShaderResourceBindings().
|
overridevirtual |
Reimplemented from QRhiTexture.
Definition at line 6343 of file qrhivulkan.cpp.
References QVkTexture::UsageState::layout, and usageState.
Definition at line 6112 of file qrhivulkan.cpp.
References QVkTexture::UsageState::access, QRhiTexture::CubeMap, destroy(), QSize::isEmpty(), QVkTexture::UsageState::layout, QRhiTexture::m_arraySize, QRhiTexture::m_depth, QRhiTexture::m_flags, QRhiTexture::m_format, QRhiTexture::m_pixelSize, QRhiTexture::m_sampleCount, QRhi::MAX_MIP_LEVELS, mipLevelCount, QRhiTexture::MipMapped, QRhiTexture::OneDimensional, qMax(), QRHI_RES_RHI, qWarning, QVkTexture::UsageState::stage, QRhiTexture::TextureArray, QRhiTexture::ThreeDimensional, toVkTextureFormat(), usageState, vkformat, and QSize::width().
Referenced by create(), and createFrom().
|
overridevirtual |
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API directly needs special care when it comes to image layouts.
This function allows communicating the expected layout the image backing the QRhiTexture is in after the native rendering commands.
For example, consider rendering into a QRhiTexture's VkImage directly with Vulkan in a code block enclosed by QRhiCommandBuffer::beginExternal() and QRhiCommandBuffer::endExternal(), followed by using the image for texture sampling in a QRhi-based render pass. To avoid potentially incorrect image layout transitions, this function can be used to indicate what the image layout will be once the commands recorded in said code block complete.
Calling this function makes sense only after QRhiCommandBuffer::endExternal() and before a subsequent QRhiCommandBuffer::beginPass().
This function has no effect with QRhi backends where the underlying graphics API does not expose a concept of image layouts.
VkImageLayout
. With Direct 3D 12 layout is a value composed of the bits from D3D12_RESOURCE_STATES
. Reimplemented from QRhiTexture.
Definition at line 6348 of file qrhivulkan.cpp.
References layout, QVkTexture::UsageState::layout, and usageState.
|
friend |
Definition at line 129 of file qrhivulkan_p.h.
uint QVkTexture::generation = 0 |
Definition at line 128 of file qrhivulkan_p.h.
Referenced by finishCreate(), QRhiVulkan::setShaderResources(), and QRhiVulkan::updateShaderResourceBindings().
VkImage QVkTexture::image = VK_NULL_HANDLE |
Definition at line 108 of file qrhivulkan_p.h.
Referenced by QVkTextureRenderTarget::create(), destroy(), QRhiVulkan::dispatch(), QRhiVulkan::enqueueResourceUpdates(), finishCreate(), imageViewForLevel(), QRhiVulkan::recordTransitionPassResources(), and QRhiVulkan::trackedImageBarrier().
Definition at line 110 of file qrhivulkan_p.h.
VkImageView QVkTexture::imageView = VK_NULL_HANDLE |
Definition at line 109 of file qrhivulkan_p.h.
Referenced by QVkTextureRenderTarget::create(), destroy(), finishCreate(), and QRhiVulkan::updateShaderResourceBindings().
int QVkTexture::lastActiveFrameSlot = -1 |
Definition at line 127 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::activateTextureRenderTarget(), QVkRenderBuffer::destroy(), destroy(), QRhiVulkan::enqueueResourceUpdates(), finishCreate(), and QRhiVulkan::setShaderResources().
uint QVkTexture::mipLevelCount = 0 |
Definition at line 125 of file qrhivulkan_p.h.
Referenced by create(), QRhiVulkan::enqueueResourceUpdates(), finishCreate(), imageViewForLevel(), and prepareCreate().
bool QVkTexture::owns = true |
Definition at line 114 of file qrhivulkan_p.h.
Referenced by create(), createFrom(), and destroy().
VkImageView QVkTexture::perLevelImageViews[QRhi::MAX_MIP_LEVELS] |
Definition at line 113 of file qrhivulkan_p.h.
Referenced by QVkTexture(), destroy(), and imageViewForLevel().
VkSampleCountFlagBits QVkTexture::samples |
Definition at line 126 of file qrhivulkan_p.h.
Referenced by create(), QVkTextureRenderTarget::create(), QRhiVulkan::createOffscreenRenderPass(), and QRhiVulkan::enqueueResourceUpdates().
QVkAlloc QVkTexture::stagingAllocations[QVK_FRAMES_IN_FLIGHT] |
Definition at line 112 of file qrhivulkan_p.h.
Referenced by QVkTexture(), destroy(), and QRhiVulkan::enqueueResourceUpdates().
VkBuffer QVkTexture::stagingBuffers[QVK_FRAMES_IN_FLIGHT] |
Definition at line 111 of file qrhivulkan_p.h.
Referenced by QVkTexture(), destroy(), and QRhiVulkan::enqueueResourceUpdates().
UsageState QVkTexture::usageState |
Definition at line 123 of file qrhivulkan_p.h.
Referenced by createFrom(), QRhiVulkan::dispatch(), QRhiVulkan::enqueueResourceUpdates(), nativeTexture(), prepareCreate(), setNativeLayout(), QRhiVulkan::trackedImageBarrier(), and QRhiVulkan::trackedRegisterTexture().
VkFormat QVkTexture::vkformat |
Definition at line 124 of file qrhivulkan_p.h.
Referenced by QVkRenderBuffer::create(), create(), QVkTextureRenderTarget::create(), QRhiVulkan::createOffscreenRenderPass(), finishCreate(), imageViewForLevel(), and prepareCreate().