/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererCore/Textures/Texture2DResource.h
110 строк
4 KB
Sanakan8472
Pipeline State Objects (#1551)
04 май 2025, 15:48
Не верифицирован
04 май 2025, 15:48
fe7179e
Код
Авторство
О чём код?
#pragma once #include <RendererCore/RendererCoreDLL.h> #include <Core/ResourceManager/Resource.h> #include <Core/ResourceManager/ResourceTypeLoader.h> #include <Foundation/IO/MemoryStream.h> #include <RendererCore/Pipeline/Declarations.h> #include <RendererCore/RenderContext/Implementation/RenderContextStructs.h> #include <RendererFoundation/Descriptors/Descriptors.h> #include <RendererFoundation/RendererFoundationDLL.h> class ezImage; using ezTexture2DResourceHandle = ezTypedResourceHandle<class ezTexture2DResource>; /// \brief Use this descriptor in calls to ezResourceManager::CreateResource<ezTexture2DResource> to create textures from data in memory. struct EZ_RENDERERCORE_DLL ezTexture2DResourceDescriptor { /// Describes the texture format, etc. ezGALTextureCreationDescription m_DescGAL; ezGALSamplerStateCreationDescription m_SamplerDesc; /// How many quality levels can be discarded and reloaded. For created textures this can currently only be 0 or 1. ezUInt8 m_uiQualityLevelsDiscardable = 0; /// How many additional quality levels can be loaded (typically from file). ezUInt8 m_uiQualityLevelsLoadable = 0; /// One memory desc per (array * faces * mipmap) (in that order) (array is outer loop, mipmap is inner loop). Can be empty to not /// initialize data. ezArrayPtr<ezGALSystemMemoryDescription> m_InitialContent; }; class EZ_RENDERERCORE_DLL ezTexture2DResource : public ezResource { EZ_ADD_DYNAMIC_REFLECTION(ezTexture2DResource, ezResource); EZ_RESOURCE_DECLARE_COMMON_CODE(ezTexture2DResource); EZ_RESOURCE_DECLARE_CREATEABLE(ezTexture2DResource, ezTexture2DResourceDescriptor); public: ezTexture2DResource(); EZ_ALWAYS_INLINE ezGALResourceFormat::Enum GetFormat() const { return m_Format; } EZ_ALWAYS_INLINE ezUInt32 GetWidth() const { return m_uiWidth; } EZ_ALWAYS_INLINE ezUInt32 GetHeight() const { return m_uiHeight; } EZ_ALWAYS_INLINE ezGALTextureType::Enum GetType() const { return m_Type; } static void FillOutDescriptor(ezTexture2DResourceDescriptor& ref_td, const ezImage* pImage, bool bSRGB, ezUInt32 uiNumMipLevels, ezUInt32& out_uiMemoryUsed, ezHybridArray<ezGALSystemMemoryDescription, 32>& ref_initData); const ezGALTextureHandle& GetGALTexture() const { return m_hGALTexture[m_uiLoadedTextures - 1]; } const ezGALSamplerStateHandle& GetGALSamplerState() const { return m_hSamplerState; } protected: virtual ezResourceLoadDesc UnloadData(Unload WhatToUnload) override; virtual ezResourceLoadDesc UpdateContent(ezStreamReader* Stream) override; virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override; ezTexture2DResource(DoUpdate ResourceUpdateThread); ezUInt8 m_uiLoadedTextures = 0; ezGALTextureHandle m_hGALTexture[2]; ezUInt32 m_uiMemoryGPU[2] = {0, 0}; ezGALTextureType::Enum m_Type = ezGALTextureType::Invalid; ezGALResourceFormat::Enum m_Format = ezGALResourceFormat::Invalid; ezUInt32 m_uiWidth = 0; ezUInt32 m_uiHeight = 0; ezGALSamplerStateHandle m_hSamplerState; }; ////////////////////////////////////////////////////////////////////////// using ezRenderToTexture2DResourceHandle = ezTypedResourceHandle<class ezRenderToTexture2DResource>; struct EZ_RENDERERCORE_DLL ezRenderToTexture2DResourceDescriptor { ezUInt32 m_uiWidth = 0; ezUInt32 m_uiHeight = 0; ezEnum<ezGALMSAASampleCount> m_SampleCount; ezEnum<ezGALResourceFormat> m_Format = ezGALResourceFormat::RGBAUByteNormalizedsRGB; ezGALSamplerStateCreationDescription m_SamplerDesc; ezArrayPtr<ezGALSystemMemoryDescription> m_InitialContent; }; class EZ_RENDERERCORE_DLL ezRenderToTexture2DResource : public ezTexture2DResource { EZ_ADD_DYNAMIC_REFLECTION(ezRenderToTexture2DResource, ezTexture2DResource); EZ_RESOURCE_DECLARE_COMMON_CODE(ezRenderToTexture2DResource); EZ_RESOURCE_DECLARE_CREATEABLE(ezRenderToTexture2DResource, ezRenderToTexture2DResourceDescriptor); public: ezGALRenderTargetViewHandle GetRenderTargetView() const; void AddRenderView(ezViewHandle hView); void RemoveRenderView(ezViewHandle hView); const ezDynamicArray<ezViewHandle>& GetAllRenderViews() const; private: virtual ezResourceLoadDesc UnloadData(Unload WhatToUnload) override; virtual ezResourceLoadDesc UpdateContent(ezStreamReader* Stream) override; virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override; protected: // other views that use this texture as their target ezDynamicArray<ezViewHandle> m_RenderViews; };