2016-01-07 20:40:35 -07:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
2016-06-24 05:14:10 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "VideoBackends/D3D12/D3DBase.h"
|
|
|
|
|
2016-01-07 20:40:35 -07:00
|
|
|
namespace DX12
|
|
|
|
{
|
2016-03-06 02:36:40 -07:00
|
|
|
enum TEXTURE_BIND_FLAG : u32
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
TEXTURE_BIND_FLAG_SHADER_RESOURCE = (1 << 0),
|
|
|
|
TEXTURE_BIND_FLAG_RENDER_TARGET = (1 << 1),
|
|
|
|
TEXTURE_BIND_FLAG_DEPTH_STENCIL = (1 << 2)
|
2016-03-06 02:36:40 -07:00
|
|
|
};
|
|
|
|
|
2016-01-07 20:40:35 -07:00
|
|
|
namespace D3D
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
void ReplaceRGBATexture2D(
|
|
|
|
ID3D12Resource* pTexture, const u8* buffer, unsigned int width, unsigned int height,
|
|
|
|
unsigned int src_pitch, unsigned int level,
|
|
|
|
D3D12_RESOURCE_STATES current_resource_state = D3D12_RESOURCE_STATE_COMMON);
|
|
|
|
void CleanupPersistentD3DTextureResources();
|
2016-01-07 20:40:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class D3DTexture2D
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
// there are two ways to create a D3DTexture2D object:
|
|
|
|
// either create an ID3D12Resource object, pass it to the constructor and specify what views
|
|
|
|
// to create
|
|
|
|
// or let the texture automatically be created by D3DTexture2D::Create
|
|
|
|
|
|
|
|
D3DTexture2D(ID3D12Resource* texptr, u32 bind, DXGI_FORMAT srv_format = DXGI_FORMAT_UNKNOWN,
|
|
|
|
DXGI_FORMAT dsv_format = DXGI_FORMAT_UNKNOWN,
|
|
|
|
DXGI_FORMAT rtv_format = DXGI_FORMAT_UNKNOWN, bool multisampled = false,
|
|
|
|
D3D12_RESOURCE_STATES resource_state = D3D12_RESOURCE_STATE_COMMON);
|
|
|
|
static D3DTexture2D* Create(unsigned int width, unsigned int height, u32 bind, DXGI_FORMAT fmt,
|
|
|
|
unsigned int levels = 1, unsigned int slices = 1,
|
|
|
|
D3D12_SUBRESOURCE_DATA* data = nullptr);
|
|
|
|
void TransitionToResourceState(ID3D12GraphicsCommandList* command_list,
|
|
|
|
D3D12_RESOURCE_STATES state_after);
|
|
|
|
|
|
|
|
// reference counting, use AddRef() when creating a new reference and Release() it when you don't
|
|
|
|
// need it anymore
|
|
|
|
void AddRef();
|
|
|
|
UINT Release();
|
|
|
|
|
|
|
|
ID3D12Resource* GetTex12() const;
|
|
|
|
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE GetSRV12CPU() const;
|
|
|
|
D3D12_GPU_DESCRIPTOR_HANDLE GetSRV12GPU() const;
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE GetSRV12GPUCPUShadow() const;
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE GetDSV12() const;
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE GetRTV12() const;
|
|
|
|
|
|
|
|
D3D12_RESOURCE_STATES GetResourceUsageState() const;
|
|
|
|
|
|
|
|
bool GetMultisampled() const;
|
2016-01-07 20:40:35 -07:00
|
|
|
|
|
|
|
private:
|
2016-06-24 02:43:46 -06:00
|
|
|
~D3DTexture2D();
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
ID3D12Resource* m_tex12 = nullptr;
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE m_srv12_cpu = {};
|
|
|
|
D3D12_GPU_DESCRIPTOR_HANDLE m_srv12_gpu = {};
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE m_srv12_gpu_cpu_shadow = {};
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE m_dsv12 = {};
|
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE m_rtv12 = {};
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
D3D12_RESOURCE_STATES m_resource_state = D3D12_RESOURCE_STATE_COMMON;
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool m_multisampled = false;
|
2016-01-07 20:40:35 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::atomic<unsigned long> m_ref = 1;
|
2016-01-07 20:40:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DX12
|