Formalize cubemap skybox pipeline across backends
This commit is contained in:
@@ -19,9 +19,9 @@ public:
|
||||
|
||||
bool Initialize(ID3D12Device* device, const D3D12_RESOURCE_DESC& desc, D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON);
|
||||
bool InitializeFromExisting(ID3D12Resource* resource, bool ownsResource = false);
|
||||
bool InitializeFromData(ID3D12Device* device, ID3D12GraphicsCommandList* commandList,
|
||||
const void* pixelData, uint32_t width, uint32_t height, DXGI_FORMAT format, uint32_t rowPitch = 0,
|
||||
ComPtr<ID3D12Resource>* uploadBuffer = nullptr);
|
||||
bool InitializeFromData(ID3D12Device* device, ID3D12GraphicsCommandList* commandList,
|
||||
const D3D12_RESOURCE_DESC& textureDesc, TextureType textureType, const void* pixelData, size_t pixelDataSize,
|
||||
uint32_t rowPitch = 0, ComPtr<ID3D12Resource>* uploadBuffer = nullptr);
|
||||
bool InitializeDepthStencil(ID3D12Device* device, uint32_t width, uint32_t height, DXGI_FORMAT format = DXGI_FORMAT_D24_UNORM_S8_UINT);
|
||||
void Shutdown() override;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ struct DescriptorBinding {
|
||||
uint32_t count;
|
||||
std::vector<uint32_t> textureUnits;
|
||||
std::vector<uint32_t> textureIds;
|
||||
std::vector<uint32_t> textureTargets;
|
||||
std::vector<uint32_t> samplerIds;
|
||||
};
|
||||
|
||||
|
||||
@@ -147,16 +147,21 @@ inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material*
|
||||
|
||||
if (const Resources::ShaderPropertyDesc* property = FindShaderPropertyBySemantic(material, "SkyboxTexture")) {
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle = material->GetTexture(property->name);
|
||||
if (textureHandle.Get() != nullptr && textureHandle->IsValid()) {
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
(textureHandle->GetTextureType() == Resources::TextureType::TextureCube ||
|
||||
textureHandle->GetTextureType() == Resources::TextureType::TextureCubeArray)) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* kSkyboxTexturePropertyNames[] = {
|
||||
"_Tex",
|
||||
"_MainTex",
|
||||
"_PanoramicTex",
|
||||
"_Cube",
|
||||
"_SkyboxTexture",
|
||||
"panoramicTexture",
|
||||
"cubemap",
|
||||
"skyboxCubemap",
|
||||
"skyboxTexture",
|
||||
"texture"
|
||||
};
|
||||
@@ -164,7 +169,10 @@ inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material*
|
||||
for (const char* propertyName : kSkyboxTexturePropertyNames) {
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle =
|
||||
material->GetTexture(Containers::String(propertyName));
|
||||
if (textureHandle.Get() != nullptr && textureHandle->IsValid()) {
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
(textureHandle->GetTextureType() == Resources::TextureType::TextureCube ||
|
||||
textureHandle->GetTextureType() == Resources::TextureType::TextureCubeArray)) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,8 +285,10 @@ private:
|
||||
std::unordered_map<DynamicDescriptorSetKey, CachedDescriptorSet, DynamicDescriptorSetKeyHash> m_dynamicDescriptorSets;
|
||||
RHI::RHISampler* m_sampler = nullptr;
|
||||
RHI::RHISampler* m_shadowSampler = nullptr;
|
||||
RHI::RHITexture* m_fallbackTexture = nullptr;
|
||||
RHI::RHIResourceView* m_fallbackTextureView = nullptr;
|
||||
RHI::RHITexture* m_fallbackTexture2D = nullptr;
|
||||
RHI::RHIResourceView* m_fallbackTexture2DView = nullptr;
|
||||
RHI::RHITexture* m_fallbackTextureCube = nullptr;
|
||||
RHI::RHIResourceView* m_fallbackTextureCubeView = nullptr;
|
||||
RHI::RHIPipelineLayout* m_skyboxPipelineLayout = nullptr;
|
||||
RHI::RHIPipelineState* m_skyboxPipelineState = nullptr;
|
||||
OwnedDescriptorSet m_skyboxEnvironmentSet = {};
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
bool Create(Core::uint32 width, Core::uint32 height, Core::uint32 depth,
|
||||
Core::uint32 mipLevels, TextureType type, TextureFormat format,
|
||||
const void* data, size_t dataSize);
|
||||
const void* data, size_t dataSize, Core::uint32 arraySize = 1);
|
||||
bool GenerateMipmaps();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user