mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 05:45:45 -04:00
D3D11: Support mipmaps in wrapper textures
This commit is contained in:
@ -28,10 +28,11 @@ D3D11_TEXTURE2D_DESC Texture::GetDesc() const
|
||||
return desc;
|
||||
}
|
||||
|
||||
bool Texture::Create(ID3D11Device* device, u32 width, u32 height, u32 samples, DXGI_FORMAT format, u32 bind_flags,
|
||||
const void* initial_data /* = nullptr */, u32 initial_data_stride /* = 0 */, bool dynamic)
|
||||
bool Texture::Create(ID3D11Device* device, u32 width, u32 height, u16 levels, u16 samples, DXGI_FORMAT format,
|
||||
u32 bind_flags, const void* initial_data /* = nullptr */, u32 initial_data_stride /* = 0 */,
|
||||
bool dynamic)
|
||||
{
|
||||
CD3D11_TEXTURE2D_DESC desc(format, width, height, 1, 1, bind_flags,
|
||||
CD3D11_TEXTURE2D_DESC desc(format, width, height, 1, levels, bind_flags,
|
||||
dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT, dynamic ? D3D11_CPU_ACCESS_WRITE : 0,
|
||||
samples, 0, 0);
|
||||
|
||||
@ -79,9 +80,10 @@ bool Texture::Create(ID3D11Device* device, u32 width, u32 height, u32 samples, D
|
||||
m_texture = std::move(texture);
|
||||
m_srv = std::move(srv);
|
||||
m_rtv = std::move(rtv);
|
||||
m_width = desc.Width;
|
||||
m_height = desc.Height;
|
||||
m_samples = desc.SampleDesc.Count;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_levels = levels;
|
||||
m_samples = samples;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -123,7 +125,8 @@ bool Texture::Adopt(ID3D11Device* device, ComPtr<ID3D11Texture2D> texture)
|
||||
m_rtv = std::move(rtv);
|
||||
m_width = desc.Width;
|
||||
m_height = desc.Height;
|
||||
m_samples = desc.SampleDesc.Count;
|
||||
m_levels = static_cast<u16>(desc.MipLevels);
|
||||
m_samples = static_cast<u16>(desc.SampleDesc.Count);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -134,6 +137,7 @@ void Texture::Destroy()
|
||||
m_texture.Reset();
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_levels = 0;
|
||||
m_samples = 0;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@ public:
|
||||
|
||||
ALWAYS_INLINE u32 GetWidth() const { return m_width; }
|
||||
ALWAYS_INLINE u32 GetHeight() const { return m_height; }
|
||||
ALWAYS_INLINE u32 GetSamples() const { return m_samples; }
|
||||
ALWAYS_INLINE u16 GetLevels() const { return m_levels; }
|
||||
ALWAYS_INLINE u16 GetSamples() const { return m_samples; }
|
||||
ALWAYS_INLINE bool IsMultisampled() const { return m_samples > 1; }
|
||||
ALWAYS_INLINE DXGI_FORMAT GetFormat() const { return GetDesc().Format; }
|
||||
D3D11_TEXTURE2D_DESC GetDesc() const;
|
||||
@ -33,7 +34,7 @@ public:
|
||||
ALWAYS_INLINE operator ID3D11RenderTargetView*() const { return m_rtv.Get(); }
|
||||
ALWAYS_INLINE operator bool() const { return static_cast<bool>(m_texture); }
|
||||
|
||||
bool Create(ID3D11Device* device, u32 width, u32 height, u32 samples, DXGI_FORMAT format, u32 bind_flags,
|
||||
bool Create(ID3D11Device* device, u32 width, u32 height, u16 levels, u16 samples, DXGI_FORMAT format, u32 bind_flags,
|
||||
const void* initial_data = nullptr, u32 initial_data_stride = 0, bool dynamic = false);
|
||||
bool Adopt(ID3D11Device* device, ComPtr<ID3D11Texture2D> texture);
|
||||
|
||||
@ -45,6 +46,7 @@ private:
|
||||
ComPtr<ID3D11RenderTargetView> m_rtv;
|
||||
u32 m_width;
|
||||
u32 m_height;
|
||||
u32 m_samples;
|
||||
u16 m_levels;
|
||||
u16 m_samples;
|
||||
};
|
||||
} // namespace D3D11
|
Reference in New Issue
Block a user