5.6 KiB
Juliet\src\Graphics\D3D12\D3D12Texture
Source Files
- Header:
Juliet\src\Graphics\D3D12\D3D12Texture.h - Source:
Juliet\src\Graphics\D3D12\D3D12Texture.cpp
AI Description
It looks like you're working with a graphics library that handles DirectX 12 resources, specifically textures. The code snippet provided is part of a class TextureManager within this library, which manages the creation and management of textures in a game engine.
Here's a breakdown of what the code does:
Texture Management
-
Texture Formats:
- The
JulietToD3D12_DepthFormatarray maps Juliet texture formats to their corresponding D3D12 depth formats. - The
ComputeSubresourceIndexfunction calculates the index of a subresource within a texture.
- The
-
Resource States:
- The
GetDefaultTextureResourceStatefunction determines the default resource state based on the usage flags of the texture. - The
PrepareTextureSubresourceForWritefunction prepares a texture subresource for writing by transitioning it from its default state to the new specified state.
- The
-
Fetching Subresources:
- The
FetchTextureSubresourcefunction retrieves a specific subresource from a texture container.
- The
-
Resource Barriers:
- The
TextureSubresourceBarrierfunction applies a resource barrier to transition between different resource states. - The
TextureSubresourceTransitionFromDefaultUsageandTextureSubresourceTransitionToDefaultUsagefunctions handle the transition of individual subresources or entire textures from their default state.
- The
Usage
- Prepare Texture Subresource for Write: This function prepares a texture subresource for writing by transitioning it to the specified usage state.
- Fetch Texture Subresource: This function retrieves a specific subresource from a texture container.
- Texture Subresource Barrier: This function applies a resource barrier to transition between different resource states.
Example Usage
Here's an example of how you might use these functions in a game engine:
NonNullPtr?D3D12CommandList? commandList = ...; // Get the command list
NonNullPtr?D3D12TextureContainer? container = ...; // Get the texture container
// Prepare a texture subresource for writing
NonNullPtr?D3D12TextureSubresource? subresource = Internal::PrepareTextureSubresourceForWrite(commandList, container, 0, 0, true, D3D12_RESOURCE_STATE_RENDER_TARGET);
// Fetch a specific subresource from the texture container
NonNullPtr?D3D12TextureSubresource? fetchedSubresource = Internal::FetchTextureSubresource(container, 0, 0);
// Apply a resource barrier to transition the subresource to render target state
Internal::TextureSubresourceBarrier(commandList, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, fetchedSubresource);
This code snippet demonstrates how to prepare and manage texture resources in a game engine using DirectX 12.
Symbols
Namespace Juliet::D3D12
Classes, Structs & Unions
struct D3D12TextureContainerstruct D3D12TextureSubresourcestruct D3D12Texture
Functions & Methods
-
`// namespace Internal
extern Texture* CreateTexture(NonNullPtr driver, const TextureCreateInfo& createInfo)`
-
extern void DestroyTexture(NonNullPtr<GPUDriver> driver, NonNullPtr<Texture> texture)
Namespace Juliet::D3D12::Internal
Functions & Methods
extern D3D12TextureSubresource* PrepareTextureSubresourceForWrite(NonNullPtr<D3D12CommandList>, NonNullPtr<D3D12TextureContainer> container, uint32 layer, uint32 level, bool shouldCycle, D3D12_RESOURCE_STATES newTextureUsage)extern D3D12TextureSubresource* FetchTextureSubresource(NonNullPtr<D3D12TextureContainer> container, uint32 layer, uint32 level)extern void TextureSubresourceBarrier(NonNullPtr<D3D12CommandList> commandList, D3D12_RESOURCE_STATES sourceState, D3D12_RESOURCE_STATES destinationState, NonNullPtr<D3D12TextureSubresource> textureSubresource)// Texture usage transition extern void TextureSubresourceTransitionFromDefaultUsage(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12TextureSubresource> subresource, D3D12_RESOURCE_STATES toTextureUsage)extern void TextureTransitionFromDefaultUsage(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12Texture> texture, D3D12_RESOURCE_STATES toTextureUsage)extern void TextureSubresourceTransitionToDefaultUsage(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12TextureSubresource> subresource, D3D12_RESOURCE_STATES fromTextureUsage)extern void TextureTransitionToDefaultUsage(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12Texture> texture, D3D12_RESOURCE_STATES fromTextureUsage)// Utils extern DXGI_FORMAT ConvertToD3D12TextureFormat(TextureFormat format)extern DXGI_FORMAT ConvertToD3D12DepthFormat(TextureFormat format)