RHI: 增强RHIResourceView抽象接口,添加GetViewType/GetDimension/GetFormat虚函数
- 在RHIResourceView基类添加3个纯虚函数:GetViewType()、GetDimension()、GetFormat() - D3D12ResourceView和OpenGLResourceView子类实现这些虚函数 - 在各InitializeAs*方法中正确存储format和dimension信息 - 消除调用者必须向下转型才能获取视图类型的需求
This commit is contained in:
@@ -24,7 +24,9 @@ public:
|
||||
bool IsValid() const override;
|
||||
|
||||
void SetViewType(ResourceViewType type) { m_viewType = type; }
|
||||
ResourceViewType GetViewType() const { return m_viewType; }
|
||||
ResourceViewType GetViewType() const override { return m_viewType; }
|
||||
ResourceViewDimension GetDimension() const override { return m_dimension; }
|
||||
Format GetFormat() const override { return m_format; }
|
||||
|
||||
void InitializeAsRenderTarget(ID3D12Device* device, ID3D12Resource* resource,
|
||||
const D3D12_RENDER_TARGET_VIEW_DESC* desc,
|
||||
@@ -55,6 +57,8 @@ public:
|
||||
|
||||
private:
|
||||
ResourceViewType m_viewType;
|
||||
Format m_format;
|
||||
ResourceViewDimension m_dimension;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE m_handle;
|
||||
ID3D12Resource* m_resource;
|
||||
D3D12DescriptorHeap* m_heap;
|
||||
|
||||
@@ -46,7 +46,9 @@ public:
|
||||
const ResourceViewDesc& desc,
|
||||
OpenGLUniformBufferManager* manager);
|
||||
|
||||
ResourceViewType GetViewType() const { return m_viewType; }
|
||||
ResourceViewType GetViewType() const override { return m_viewType; }
|
||||
ResourceViewDimension GetDimension() const override { return m_dimension; }
|
||||
Format GetFormat() const override { return m_format; }
|
||||
unsigned int GetFramebuffer() const;
|
||||
int32_t GetTextureUnit() const { return m_textureUnit; }
|
||||
int32_t GetBindingPoint() const { return m_bindingPoint; }
|
||||
@@ -55,6 +57,8 @@ public:
|
||||
|
||||
private:
|
||||
ResourceViewType m_viewType;
|
||||
Format m_format;
|
||||
ResourceViewDimension m_dimension;
|
||||
unsigned int m_framebufferID;
|
||||
int32_t m_textureUnit;
|
||||
int32_t m_bindingPoint;
|
||||
|
||||
@@ -15,6 +15,10 @@ public:
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
virtual ResourceViewType GetViewType() const = 0;
|
||||
virtual ResourceViewDimension GetDimension() const = 0;
|
||||
virtual Format GetFormat() const = 0;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
|
||||
Reference in New Issue
Block a user