summaryrefslogtreecommitdiffstats
path: root/Tests/TestApp/src
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-12-01 07:15:55 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-12-01 07:15:55 +0000
commit82d59de0d193554e1231b06347078d41ed8ec8d3 (patch)
treeb4d723394dd870f4e7a3201e3e804c88ff4aad7f /Tests/TestApp/src
parentUpdated submodules (added DRAW_FLAG_VERIFY_STATES & DISPATCH_FLAG_VERIFY_STAT... (diff)
downloadDiligentEngine-82d59de0d193554e1231b06347078d41ed8ec8d3.tar.gz
DiligentEngine-82d59de0d193554e1231b06347078d41ed8ec8d3.zip
Improved thread safety of enum flags; added explicit state transitions to SetRenderTargets()
Diffstat (limited to 'Tests/TestApp/src')
-rw-r--r--Tests/TestApp/src/TestApp.cpp16
-rw-r--r--Tests/TestApp/src/TestBufferAccess.cpp4
-rw-r--r--Tests/TestApp/src/TestDepthStencilState.cpp5
-rw-r--r--Tests/TestApp/src/TestDrawCommands.cpp2
-rw-r--r--Tests/TestApp/src/TestSeparateTextureSampler.cpp4
-rw-r--r--Tests/TestApp/src/TestShaderResourceLayout.cpp2
-rw-r--r--Tests/TestApp/src/TestShaderVarAccess.cpp4
-rw-r--r--Tests/TestApp/src/TestTextureCreation.cpp22
8 files changed, 32 insertions, 27 deletions
diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp
index 92789a8..0c05ae3 100644
--- a/Tests/TestApp/src/TestApp.cpp
+++ b/Tests/TestApp/src/TestApp.cpp
@@ -442,7 +442,7 @@ void TestApp::InitializeRenderers()
BuffDesc.uiSizeInBytes = sizeof(UniformData);
BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
BuffDesc.Usage = USAGE_DEFAULT;
- BuffDesc.CPUAccessFlags = 0;
+ BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE;
Diligent::BufferData BuffData;
BuffData.pData = UniformData;
BuffData.DataSize = sizeof(UniformData);
@@ -456,7 +456,7 @@ void TestApp::InitializeRenderers()
BuffDesc.uiSizeInBytes = sizeof(UniformData);
BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
BuffDesc.Usage = USAGE_DEFAULT;
- BuffDesc.CPUAccessFlags = 0;
+ BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE;
Diligent::BufferData BuffData;
BuffData.pData = UniformData;
BuffData.DataSize = sizeof(UniformData);
@@ -522,7 +522,7 @@ void TestApp::InitializeRenderers()
UniformData[3] = 0;
}
- m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr);
+ m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f};
m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor);
DrawAttribs DrawAttrs;
@@ -531,12 +531,12 @@ void TestApp::InitializeRenderers()
m_pRenderScript->Run(m_pImmediateContext, "DrawTris", DrawAttrs);
// This adds transition barrier for pTex1
- m_pImmediateContext->SetRenderTargets(1, pRTVs, pDSV);
+ m_pImmediateContext->SetRenderTargets(1, pRTVs, pDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
m_pImmediateContext->ClearRenderTarget(pRTVs[0], ClearColor);
m_pImmediateContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG);
// Generate draw command to the bound render target
m_pImmediateContext->Draw(DrawAttrs);
- m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr);
+ m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
// This will destroy texture and put D3D12 resource into release queue
pTex.Release();
@@ -547,7 +547,7 @@ void TestApp::InitializeRenderers()
BuffDesc.uiSizeInBytes = sizeof(Data);
BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
BuffDesc.Usage = USAGE_DEFAULT;
- BuffDesc.CPUAccessFlags = 0;
+ BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE;
Diligent::BufferData BuffData;
BuffData.pData = Data;
BuffData.DataSize = sizeof(Data);
@@ -630,11 +630,11 @@ void TestApp::Update(double CurrTime, double ElapsedTime)
void TestApp::Render()
{
- m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr);
+ m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f};
m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor);
m_pImmediateContext->ClearDepthStencil(nullptr, CLEAR_DEPTH_FLAG, 1.f);
-
+
double dCurrTime = m_CurrTime;
float instance_offsets[] = { -0.3f, (float)sin(dCurrTime + 0.5)*0.1f, 0.0f, (float)sin(dCurrTime)*0.1f, +0.3f, -0.3f + (float)cos(dCurrTime)*0.1f };
diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp
index 0a31142..ac36264 100644
--- a/Tests/TestApp/src/TestBufferAccess.cpp
+++ b/Tests/TestApp/src/TestBufferAccess.cpp
@@ -226,7 +226,7 @@ void TestBufferAccess::Draw(float fTime)
// Test reading data from staging resource
{
m_pDeviceContext->CopyBuffer(m_pInstBuff[3], 0, m_pInstBuff[4], 0, sizeof( instance_offsets ) );
- pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, 0 );
+ pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, MAP_FLAG_NONE );
for(int i = 0; i < _countof(instance_offsets); ++i)
assert(pStagingData[i] == instance_offsets[i]);
pStagingData.Unmap();
@@ -237,7 +237,7 @@ void TestBufferAccess::Draw(float fTime)
{
// Test writing data to staging resource
{
- pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, 0 );
+ pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, MAP_FLAG_NONE );
for(int Inst = 0; Inst < NumInstances; ++Inst)
{
pStagingData[Inst*2] = (1+Inst) * fDX;
diff --git a/Tests/TestApp/src/TestDepthStencilState.cpp b/Tests/TestApp/src/TestDepthStencilState.cpp
index f8fbef1..52e491a 100644
--- a/Tests/TestApp/src/TestDepthStencilState.cpp
+++ b/Tests/TestApp/src/TestDepthStencilState.cpp
@@ -35,6 +35,11 @@ void TestDepthStencilState::CreateTestDSS( DepthStencilStateDesc &DSSDesc )
RefCntAutoPtr<IPipelineState> pPSO;
m_pDevice->CreatePipelineState( m_PSODesc, &pPSO );
m_pDeviceContext->SetPipelineState( pPSO );
+
+ RefCntAutoPtr<IShaderResourceBinding> pSRB;
+ pPSO->CreateShaderResourceBinding(&pSRB);
+ auto PSVarCount = pSRB->GetVariableCount(SHADER_TYPE_PIXEL);
+ auto VSVarCount = pSRB->GetVariableCount(SHADER_TYPE_VERTEX);
#if 0
DSSDesc.Name = "TestDSS2";
m_pDevice->CreateDepthStencilState( DSSDesc, &pDSState2 );
diff --git a/Tests/TestApp/src/TestDrawCommands.cpp b/Tests/TestApp/src/TestDrawCommands.cpp
index 8ddb1ab..8419b28 100644
--- a/Tests/TestApp/src/TestDrawCommands.cpp
+++ b/Tests/TestApp/src/TestDrawCommands.cpp
@@ -236,7 +236,7 @@ void TestDrawCommands::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceCont
BuffDesc.uiSizeInBytes = sizeof( UniformData );
BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
BuffDesc.Usage = USAGE_DEFAULT;
- BuffDesc.CPUAccessFlags = 0;
+ BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE;
BufferData BuffData;
BuffData.pData = UniformData;
BuffData.DataSize = sizeof( UniformData );
diff --git a/Tests/TestApp/src/TestSeparateTextureSampler.cpp b/Tests/TestApp/src/TestSeparateTextureSampler.cpp
index bc31712..d1df07e 100644
--- a/Tests/TestApp/src/TestSeparateTextureSampler.cpp
+++ b/Tests/TestApp/src/TestSeparateTextureSampler.cpp
@@ -151,7 +151,7 @@ TestSeparateTextureSampler::TestSeparateTextureSampler(IRenderDevice *pDevice, I
pDevice->CreateTexture(RenderTargetDesc, TextureData{}, &pRenderTarget);
ITextureView* pRTV[] = {pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)};
- pContext->SetRenderTargets(1, pRTV, nullptr);
+ pContext->SetRenderTargets(1, pRTV, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
float Zero[4] = {};
pContext->ClearRenderTarget(pRTV[0], Zero);
pContext->SetPipelineState(pPSO);
@@ -161,7 +161,7 @@ TestSeparateTextureSampler::TestSeparateTextureSampler(IRenderDevice *pDevice, I
DrawAttrs.NumVertices = 3;
pContext->Draw(DrawAttrs);
- pContext->SetRenderTargets(0, nullptr, nullptr);
+ pContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
SetStatus(TestResult::Succeeded);
}
diff --git a/Tests/TestApp/src/TestShaderResourceLayout.cpp b/Tests/TestApp/src/TestShaderResourceLayout.cpp
index 2ac150b..0448931 100644
--- a/Tests/TestApp/src/TestShaderResourceLayout.cpp
+++ b/Tests/TestApp/src/TestShaderResourceLayout.cpp
@@ -85,7 +85,7 @@ TestShaderResourceLayout::TestShaderResourceLayout( IRenderDevice *pDevice, IDev
RefCntAutoPtr<ITexture> pRenderTarget;
pDevice->CreateTexture(TexDesc, TextureData{}, &pRenderTarget);
auto *pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
- m_pDeviceContext->SetRenderTargets(1, &pRTV, nullptr);
+ m_pDeviceContext->SetRenderTargets(1, &pRTV, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
float Zero[4] = {};
m_pDeviceContext->ClearRenderTarget(pRTV, Zero);
diff --git a/Tests/TestApp/src/TestShaderVarAccess.cpp b/Tests/TestApp/src/TestShaderVarAccess.cpp
index dd23fd9..4b571f6 100644
--- a/Tests/TestApp/src/TestShaderVarAccess.cpp
+++ b/Tests/TestApp/src/TestShaderVarAccess.cpp
@@ -552,7 +552,7 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext
VERIFY_EXPR(pNonExistingVar == nullptr);
VERIFY_EXPR(pSRB->GetVariableCount(SHADER_TYPE_GEOMETRY) == 0);
- m_pDeviceContext->SetRenderTargets(1, &pRTV, pDSV);
+ m_pDeviceContext->SetRenderTargets(1, &pRTV, pDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
float Zero[4] = {};
m_pDeviceContext->ClearRenderTarget(pRTV, Zero);
m_pDeviceContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG);
@@ -560,7 +560,7 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext
pContext->CommitShaderResources(pSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES);
pContext->Draw(DrawAttrs);
- m_pDeviceContext->SetRenderTargets(0, nullptr, nullptr);
+ m_pDeviceContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL);
SetStatus(TestResult::Succeeded);
}
diff --git a/Tests/TestApp/src/TestTextureCreation.cpp b/Tests/TestApp/src/TestTextureCreation.cpp
index d0b2ef3..71efb5f 100644
--- a/Tests/TestApp/src/TestTextureCreation.cpp
+++ b/Tests/TestApp/src/TestTextureCreation.cpp
@@ -52,7 +52,7 @@ public:
TextureCreationVerifier( IRenderDevice *pDevice, IDeviceContext *pContext ) :
m_pDevice(pDevice),
m_pDeviceContext(pContext),
- m_BindFlags(0),
+ m_BindFlags(BIND_NONE),
m_TextureFormat(TEX_FORMAT_UNKNOWN),
m_PixelSize(0),
m_bTestDataUpload(False)
@@ -91,7 +91,7 @@ public:
void Test(TEXTURE_FORMAT TextureFormat,
Uint32 PixelSize,
- Uint32 BindFlags,
+ BIND_FLAGS BindFlags,
Bool TestDataUpload)
{
m_TextureFormat = TextureFormat;
@@ -554,7 +554,7 @@ private:
}
IRenderDevice *m_pDevice;
IDeviceContext *m_pDeviceContext;
- Uint32 m_BindFlags;
+ BIND_FLAGS m_BindFlags;
TEXTURE_FORMAT m_TextureFormat;
Uint32 m_PixelSize;
Bool m_bTestDataUpload;
@@ -568,19 +568,19 @@ TestTextureCreation::TestTextureCreation( IRenderDevice *pDevice, IDeviceContext
TestTextureFormatAttribs();
TextureCreationVerifier Verifier(pDevice, pContext);
- const Uint32 BindSRU = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
- const Uint32 BindSR = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
- //const Uint32 BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
- const Uint32 BindSU = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- const Uint32 BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
- const Uint32 BindD = BIND_DEPTH_STENCIL;
- const Uint32 BindS = BIND_SHADER_RESOURCE;
+ const BIND_FLAGS BindSRU = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
+ const BIND_FLAGS BindSR = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
+ //const BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
+ const BIND_FLAGS BindSU = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
+ const BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
+ const BIND_FLAGS BindD = BIND_DEPTH_STENCIL;
+ const BIND_FLAGS BindS = BIND_SHADER_RESOURCE;
struct TextureTestAttribs
{
TEXTURE_FORMAT Fmt;
Uint32 PixelSize;
- Uint32 BindFlags;
+ BIND_FLAGS BindFlags;
Bool TestDataUpload;
const char* Name;
};