Skip to content
Permalink
Browse files
Merge pull request #6193 from stenzek/readbacks
Abstract Staging Textures - VideoCommon interface for texture readbacks/uploads
  • Loading branch information
stenzek committed Dec 1, 2017
2 parents 0773a48 + 7f217a8 commit cd68b36
Show file tree
Hide file tree
Showing 62 changed files with 1,868 additions and 1,178 deletions.
@@ -1870,6 +1870,9 @@ const GLFunc gl_function_array[] = {
GLFUNC_REQUIRES(glDispatchCompute, "GL_ARB_compute_shader !VERSION_4_3 |VERSION_GLES_3_1"),
GLFUNC_REQUIRES(glDispatchComputeIndirect,
"GL_ARB_compute_shader !VERSION_4_3 |VERSION_GLES_3_1"),

// ARB_get_texture_sub_image
GLFUNC_REQUIRES(glGetTextureSubImage, "GL_ARB_get_texture_sub_image !VERSION_4_5"),
};

namespace GLExtensions
@@ -52,8 +52,6 @@ const D3D_FEATURE_LEVEL supported_feature_levels[NUM_SUPPORTED_FEATURE_LEVELS] =

unsigned int xres, yres;

bool bFrameInProgress = false;

HRESULT LoadDXGI()
{
if (dxgi_dll_ref++ > 0)
@@ -602,27 +600,6 @@ void Reset()
SetDebugObjectName(backbuf->GetRTV(), "backbuffer render target view");
}

bool BeginFrame()
{
if (bFrameInProgress)
{
PanicAlert("BeginFrame called although a frame is already in progress");
return false;
}
bFrameInProgress = true;
return (device != nullptr);
}

void EndFrame()
{
if (!bFrameInProgress)
{
PanicAlert("EndFrame called although no frame is in progress");
return;
}
bFrameInProgress = false;
}

void Present()
{
UINT present_flags = 0;
@@ -63,8 +63,6 @@ extern HWND hWnd;
extern bool bFrameInProgress;

void Reset();
bool BeginFrame();
void EndFrame();
void Present();

unsigned int GetBackBufferWidth();
@@ -263,6 +263,21 @@ void StateManager::SetTextureByMask(u32 textureSlotMask, ID3D11ShaderResourceVie

} // namespace D3D

StateCache::~StateCache()
{
for (auto& it : m_depth)
SAFE_RELEASE(it.second);

for (auto& it : m_raster)
SAFE_RELEASE(it.second);

for (auto& it : m_blend)
SAFE_RELEASE(it.second);

for (auto& it : m_sampler)
SAFE_RELEASE(it.second);
}

ID3D11SamplerState* StateCache::Get(SamplerState state)
{
auto it = m_sampler.find(state.hex);
@@ -471,33 +486,6 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state)
return res;
}

void StateCache::Clear()
{
for (auto it : m_depth)
{
SAFE_RELEASE(it.second);
}
m_depth.clear();

for (auto it : m_raster)
{
SAFE_RELEASE(it.second);
}
m_raster.clear();

for (auto it : m_blend)
{
SAFE_RELEASE(it.second);
}
m_blend.clear();

for (auto it : m_sampler)
{
SAFE_RELEASE(it.second);
}
m_sampler.clear();
}

D3D11_PRIMITIVE_TOPOLOGY StateCache::GetPrimitiveTopology(PrimitiveType primitive)
{
static constexpr std::array<D3D11_PRIMITIVE_TOPOLOGY, 4> primitives = {
@@ -23,16 +23,15 @@ namespace DX11
class StateCache
{
public:
~StateCache();

// Get existing or create new render state.
// Returned objects is owned by the cache and does not need to be released.
ID3D11SamplerState* Get(SamplerState state);
ID3D11BlendState* Get(BlendingState state);
ID3D11RasterizerState* Get(RasterizationState state);
ID3D11DepthStencilState* Get(DepthState state);

// Release all cached states and clear hash tables.
void Clear();

// Convert RasterState primitive type to D3D11 primitive topology.
static D3D11_PRIMITIVE_TOPOLOGY GetPrimitiveTopology(PrimitiveType primitive);

0 comments on commit cd68b36

Please sign in to comment.