mirror of
https://gitee.com/openharmony/third_party_vulkan-loader
synced 2025-01-12 10:10:36 +00:00
tests: Now have two triangle tests using different shaders
This commit is contained in:
parent
39e6b73f91
commit
2918b7a1fd
@ -200,7 +200,7 @@ public:
|
||||
void InitMesh( XGL_UINT32 numVertices, XGL_GPU_SIZE vbStride, const void* vertices );
|
||||
void InitTexture();
|
||||
void InitSampler();
|
||||
void DrawTriangleTest();
|
||||
void DrawTriangleTest(const char *vertShaderText, const char *fragShaderText);
|
||||
void DrawRotatedTriangleTest();
|
||||
void NewGenerateClearAndPrepareBufferCmds(XglImage *renderTarget);
|
||||
void NewGenerateBindStateAndPipelineCmds(XGL_PIPELINE* pipeline);
|
||||
@ -239,7 +239,7 @@ protected:
|
||||
|
||||
this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
this->app_info.pNext = NULL;
|
||||
this->app_info.pAppName = (const XGL_CHAR *) "base";
|
||||
this->app_info.pAppName = (const XGL_CHAR *) "render_tests";
|
||||
this->app_info.appVersion = 1;
|
||||
this->app_info.pEngineName = (const XGL_CHAR *) "unittest";
|
||||
this->app_info.engineVersion = 1;
|
||||
@ -484,67 +484,27 @@ void XglRenderTest::InitSampler()
|
||||
ASSERT_XGL_SUCCESS(err);
|
||||
}
|
||||
|
||||
void XglRenderTest::NewGenerateClearAndPrepareBufferCmds(XglImage *renderTarget)
|
||||
{
|
||||
// whatever we want to do, we do it to the whole buffer
|
||||
XGL_IMAGE_SUBRESOURCE_RANGE srRange = {};
|
||||
srRange.aspect = XGL_IMAGE_ASPECT_COLOR;
|
||||
srRange.baseMipLevel = 0;
|
||||
srRange.mipLevels = XGL_LAST_MIP_OR_SLICE;
|
||||
srRange.baseArraySlice = 0;
|
||||
srRange.arraySize = XGL_LAST_MIP_OR_SLICE;
|
||||
|
||||
// prepare the whole back buffer for clear
|
||||
XGL_IMAGE_STATE_TRANSITION transitionToClear = {};
|
||||
transitionToClear.image = renderTarget->image();
|
||||
transitionToClear.oldState = renderTarget->state();
|
||||
transitionToClear.newState = XGL_IMAGE_STATE_CLEAR;
|
||||
transitionToClear.subresourceRange = srRange;
|
||||
xglCmdPrepareImages( m_cmdBuffer, 1, &transitionToClear );
|
||||
renderTarget->state(( XGL_IMAGE_STATE ) transitionToClear.newState);
|
||||
|
||||
// clear the back buffer to dark grey
|
||||
XGL_UINT clearColor[4] = {64, 64, 64, 0};
|
||||
xglCmdClearColorImageRaw( m_cmdBuffer, renderTarget->image(), clearColor, 1, &srRange );
|
||||
|
||||
// prepare back buffer for rendering
|
||||
XGL_IMAGE_STATE_TRANSITION transitionToRender = {};
|
||||
transitionToRender.image = renderTarget->image();
|
||||
transitionToRender.oldState = renderTarget->state();
|
||||
transitionToRender.newState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL;
|
||||
transitionToRender.subresourceRange = srRange;
|
||||
xglCmdPrepareImages( m_cmdBuffer, 1, &transitionToRender );
|
||||
renderTarget->state(( XGL_IMAGE_STATE ) transitionToClear.newState);
|
||||
}
|
||||
|
||||
void XglRenderTest::NewGenerateBindStateAndPipelineCmds(XGL_PIPELINE* pipeline)
|
||||
{
|
||||
// set all states
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_RASTER, m_stateRaster );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_VIEWPORT, m_stateViewport );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_COLOR_BLEND, m_colorBlend);
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_DEPTH_STENCIL, m_stateDepthStencil );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_MSAA, m_stateMsaa );
|
||||
|
||||
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view)
|
||||
xglCmdBindPipeline( m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, *pipeline );
|
||||
}
|
||||
|
||||
void XglRenderTest::DrawRotatedTriangleTest()
|
||||
{
|
||||
// TODO : This test will pass a matrix into VS to affect triangle orientation.
|
||||
}
|
||||
|
||||
void XglRenderTest::DrawTriangleTest()
|
||||
void XglRenderTest::DrawTriangleTest(const char *vertShaderText, const char *fragShaderText)
|
||||
{
|
||||
XGL_PIPELINE pipeline;
|
||||
XGL_SHADER vs, ps;
|
||||
XGL_RESULT err;
|
||||
int width = 256, height = 256;
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(InitState());
|
||||
ASSERT_NO_FATAL_FAILURE(InitViewport(256.0, 256.0));
|
||||
ASSERT_NO_FATAL_FAILURE(CreateDefaultPipeline(&pipeline, &vs, &ps));
|
||||
ASSERT_NO_FATAL_FAILURE(InitViewport());
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(CreateShader(XGL_SHADER_STAGE_VERTEX,
|
||||
vertShaderText, &vs));
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(CreateShader(XGL_SHADER_STAGE_FRAGMENT,
|
||||
fragShaderText, &ps));
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(CreateDefaultPipeline(&pipeline, vs, ps));
|
||||
|
||||
/*
|
||||
* Shaders are now part of the pipeline, don't need these anymore
|
||||
@ -552,19 +512,7 @@ void XglRenderTest::DrawTriangleTest()
|
||||
ASSERT_XGL_SUCCESS(xglDestroyObject(ps));
|
||||
ASSERT_XGL_SUCCESS(xglDestroyObject(vs));
|
||||
|
||||
XGL_QUERY_POOL query;
|
||||
XGL_GPU_MEMORY query_mem;
|
||||
ASSERT_NO_FATAL_FAILURE(CreateQueryPool(XGL_QUERY_PIPELINE_STATISTICS, 1, &query, &query_mem));
|
||||
|
||||
XglImage *renderTarget;
|
||||
XGL_FORMAT fmt = {
|
||||
XGL_CH_FMT_R8G8B8A8,
|
||||
XGL_NUM_FMT_UNORM
|
||||
};
|
||||
ASSERT_NO_FATAL_FAILURE(m_device->CreateImage(width, height, fmt,
|
||||
XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT |
|
||||
XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
&renderTarget));
|
||||
ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
|
||||
|
||||
const int constantCount = 4;
|
||||
const float constants[constantCount] = { 0.5, 0.5, 0.5, 1.0 };
|
||||
@ -591,70 +539,16 @@ void XglRenderTest::DrawTriangleTest()
|
||||
err = xglBeginCommandBuffer(m_cmdBuffer, 0);
|
||||
ASSERT_XGL_SUCCESS(err);
|
||||
|
||||
GenerateClearAndPrepareBufferCmds(renderTarget);
|
||||
GenerateBindRenderTargetCmd(renderTarget);
|
||||
GenerateClearAndPrepareBufferCmds();
|
||||
GenerateBindRenderTargetCmd();
|
||||
GenerateBindStateAndPipelineCmds(&pipeline);
|
||||
|
||||
// xglCmdBindDescriptorSet(m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 );
|
||||
xglCmdBindDescriptorSet(m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 );
|
||||
}
|
||||
|
||||
void XglRenderTest::DrawRotatedTriangleTest()
|
||||
{
|
||||
// TODO : This test will pass a matrix into VS to affect triangle orientation.
|
||||
}
|
||||
|
||||
void XglRenderTest::DrawTriangleTest()
|
||||
{
|
||||
XGL_PIPELINE pipeline;
|
||||
XGL_SHADER vs, ps;
|
||||
XGL_RESULT err;
|
||||
int width = 256, height = 256;
|
||||
CreateDefaultPipeline(&pipeline, &vs, &ps, width, height);
|
||||
//ASSERT_XGL_SUCCESS(err);
|
||||
|
||||
err = m_device->AllocAndBindGpuMemory(pipeline, "Pipeline", &m_pipe_mem);
|
||||
ASSERT_XGL_SUCCESS(err);
|
||||
|
||||
/*
|
||||
* Shaders are now part of the pipeline, don't need these anymore
|
||||
*/
|
||||
ASSERT_XGL_SUCCESS(xglDestroyObject(ps));
|
||||
ASSERT_XGL_SUCCESS(xglDestroyObject(vs));
|
||||
|
||||
XGL_QUERY_POOL query;
|
||||
XGL_GPU_MEMORY query_mem;
|
||||
ASSERT_NO_FATAL_FAILURE(CreateQueryPool(XGL_QUERY_PIPELINE_STATISTICS, 1, &query, &query_mem));
|
||||
|
||||
XglImage *renderTarget;
|
||||
XGL_FORMAT fmt = {
|
||||
XGL_CH_FMT_R8G8B8A8,
|
||||
XGL_NUM_FMT_UNORM
|
||||
};
|
||||
ASSERT_NO_FATAL_FAILURE(m_device->CreateImage(width, height, fmt,
|
||||
XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT |
|
||||
XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
&renderTarget));
|
||||
|
||||
// Build command buffer
|
||||
err = xglBeginCommandBuffer(m_cmdBuffer, 0);
|
||||
ASSERT_XGL_SUCCESS(err);
|
||||
|
||||
NewGenerateClearAndPrepareBufferCmds(renderTarget);
|
||||
GenerateBindRenderTargetCmd(renderTarget);
|
||||
NewGenerateBindStateAndPipelineCmds(&pipeline);
|
||||
|
||||
// xglCmdBindDescriptorSet(m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 );
|
||||
// xglCmdBindDynamicMemoryView( m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, &m_constantBufferView );
|
||||
|
||||
xglCmdResetQueryPool(m_cmdBuffer, query, 0, 1);
|
||||
xglCmdBeginQuery(m_cmdBuffer, query, 0, 0);
|
||||
|
||||
// render the cube
|
||||
xglCmdDraw( m_cmdBuffer, 0, 3, 0, 1 );
|
||||
|
||||
xglCmdEndQuery(m_cmdBuffer, query, 0);
|
||||
|
||||
// prepare the back buffer for present
|
||||
// XGL_IMAGE_STATE_TRANSITION transitionToPresent = {};
|
||||
// transitionToPresent.image = m_image;
|
||||
@ -683,31 +577,59 @@ void XglRenderTest::DrawTriangleTest()
|
||||
// Wait for work to finish before cleaning up.
|
||||
xglDeviceWaitIdle(m_device->device());
|
||||
|
||||
XGL_PIPELINE_STATISTICS_DATA stats;
|
||||
XGL_SIZE stats_size = sizeof(stats);
|
||||
err = xglGetQueryPoolResults(query, 0, 1, &stats_size, &stats);
|
||||
ASSERT_XGL_SUCCESS( err );
|
||||
ASSERT_EQ(stats_size, sizeof(stats));
|
||||
RecordImage(m_renderTarget);
|
||||
|
||||
ASSERT_EQ(stats.vsInvocations, 3);
|
||||
ASSERT_EQ(stats.cPrimitives, 1);
|
||||
ASSERT_EQ(stats.cInvocations, 1);
|
||||
|
||||
DestroyQueryPool(query, query_mem);
|
||||
|
||||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
|
||||
// renderTarget->WritePPM(test_info->test_case_name());
|
||||
// m_screen.Display(renderTarget, m_image_mem);
|
||||
RecordImage(renderTarget);
|
||||
|
||||
free(renderTarget);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(XglRenderTest, TestDrawTriangle) {
|
||||
DrawTriangleTest();
|
||||
TEST_F(XglRenderTest, TestDrawTriangle1) {
|
||||
static const char *vertShaderText =
|
||||
"#version 130\n"
|
||||
"vec2 vertices[3];\n"
|
||||
"void main() {\n"
|
||||
" vertices[0] = vec2(-1.0, -1.0);\n"
|
||||
" vertices[1] = vec2( 1.0, -1.0);\n"
|
||||
" vertices[2] = vec2( 0.0, 1.0);\n"
|
||||
" gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char *fragShaderText =
|
||||
"#version 130\n"
|
||||
"uniform vec4 foo;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = foo;\n"
|
||||
"}\n";
|
||||
DrawTriangleTest(vertShaderText, fragShaderText);
|
||||
}
|
||||
|
||||
TEST_F(XglRenderTest, TestDrawTriangle2) {
|
||||
static const char *vertShaderText =
|
||||
"#version 330\n"
|
||||
"out vec4 color;\n"
|
||||
"out vec4 scale;\n"
|
||||
"void main() {\n"
|
||||
" vec2 vertices[3];"
|
||||
" vertices[0] = vec2(-0.5, -0.5);\n"
|
||||
" vertices[1] = vec2( 0.5, -0.5);\n"
|
||||
" vertices[2] = vec2( 0.5, 0.5);\n"
|
||||
" vec4 colors[3];\n"
|
||||
" colors[0] = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||
" colors[1] = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
" colors[2] = vec4(0.0, 0.0, 1.0, 1.0);\n"
|
||||
" color = colors[int(mod(gl_VertexID, 3))];\n"
|
||||
" scale = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||
" gl_Position = vec4(vertices[int(mod(gl_VertexID, 3))], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char *fragShaderText =
|
||||
"#version 430\n"
|
||||
"in vec4 color;\n"
|
||||
"in vec4 scale;\n"
|
||||
"layout(location = 0) uniform vec4 foo;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = color * scale + foo;\n"
|
||||
"}\n";
|
||||
DrawTriangleTest(vertShaderText, fragShaderText);
|
||||
}
|
||||
|
||||
TEST_F(XglRenderTest, TestDrawRotatedTriangle) {
|
||||
|
@ -34,7 +34,9 @@ XglRenderFramework::XglRenderFramework() :
|
||||
m_stateDepthStencil( XGL_NULL_HANDLE ),
|
||||
m_stateRaster( XGL_NULL_HANDLE ),
|
||||
m_cmdBuffer( XGL_NULL_HANDLE ),
|
||||
m_stateViewport( XGL_NULL_HANDLE )
|
||||
m_stateViewport( XGL_NULL_HANDLE ),
|
||||
m_width( 256.0 ), // default window width
|
||||
m_height( 256.0 ) // default window height
|
||||
{
|
||||
m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
|
||||
m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM;
|
||||
@ -284,6 +286,11 @@ void XglRenderFramework::InitViewport(float width, float height)
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
void XglRenderFramework::InitViewport()
|
||||
{
|
||||
InitViewport(m_width, m_height);
|
||||
}
|
||||
|
||||
void XglRenderFramework::InitRenderTarget()
|
||||
{
|
||||
m_device->CreateImage(m_width, m_height, m_render_target_fmt,
|
||||
@ -292,7 +299,7 @@ void XglRenderFramework::InitRenderTarget()
|
||||
&m_renderTarget);
|
||||
}
|
||||
|
||||
void XglRenderFramework::CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADER* vs, XGL_SHADER* ps)
|
||||
void XglRenderFramework::CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADER vs, XGL_SHADER ps)
|
||||
{
|
||||
XGL_RESULT err;
|
||||
XGL_GRAPHICS_PIPELINE_CREATE_INFO info = {};
|
||||
@ -346,69 +353,20 @@ void XglRenderFramework::CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADE
|
||||
xglAttachMemoryViewDescriptors( m_rsrcDescSet, 0, 1, &m_constantBufferView );
|
||||
xglEndDescriptorSetUpdate( m_rsrcDescSet );
|
||||
|
||||
static const char *vertShaderText =
|
||||
"#version 130\n"
|
||||
"vec2 vertices[3];\n"
|
||||
"void main() {\n"
|
||||
" vertices[0] = vec2(-1.0, -1.0);\n"
|
||||
" vertices[1] = vec2( 1.0, -1.0);\n"
|
||||
" vertices[2] = vec2( 0.0, 1.0);\n"
|
||||
" gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
static const char *vertShader2 =
|
||||
"#version 330\n"
|
||||
"out vec4 color;\n"
|
||||
"out vec4 scale;\n"
|
||||
"void main() {\n"
|
||||
" vec2 vertices[3];"
|
||||
" vertices[0] = vec2(-0.5, -0.5);\n"
|
||||
" vertices[1] = vec2( 0.5, -0.5);\n"
|
||||
" vertices[2] = vec2( 0.5, 0.5);\n"
|
||||
" vec4 colors[3];\n"
|
||||
" colors[0] = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||
" colors[1] = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
" colors[2] = vec4(0.0, 0.0, 1.0, 1.0);\n"
|
||||
" color = colors[int(mod(gl_VertexID, 3))];\n"
|
||||
" scale = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||
" gl_Position = vec4(vertices[int(mod(gl_VertexID, 3))], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(CreateShader(XGL_SHADER_STAGE_VERTEX,
|
||||
vertShader2, vs));
|
||||
|
||||
vs_stage.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
vs_stage.pNext = XGL_NULL_HANDLE;
|
||||
vs_stage.shader.stage = XGL_SHADER_STAGE_VERTEX;
|
||||
vs_stage.shader.shader = *vs;
|
||||
vs_stage.shader.shader = vs;
|
||||
vs_stage.shader.descriptorSetMapping[0].descriptorCount = 0;
|
||||
vs_stage.shader.linkConstBufferCount = 0;
|
||||
vs_stage.shader.pLinkConstBufferInfo = XGL_NULL_HANDLE;
|
||||
vs_stage.shader.dynamicMemoryViewMapping.slotObjectType = XGL_SLOT_UNUSED;
|
||||
vs_stage.shader.dynamicMemoryViewMapping.shaderEntityIndex = 0;
|
||||
|
||||
static const char *fragShaderText =
|
||||
"#version 130\n"
|
||||
"uniform vec4 foo;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = foo;\n"
|
||||
"}\n";
|
||||
static const char *fragShader2 =
|
||||
"#version 430\n"
|
||||
"in vec4 color;\n"
|
||||
"in vec4 scale;\n"
|
||||
"layout(location = 0) uniform vec4 foo;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = color * scale + foo;\n"
|
||||
"}\n";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(CreateShader(XGL_SHADER_STAGE_FRAGMENT,
|
||||
fragShader2, ps));
|
||||
|
||||
ps_stage.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
ps_stage.pNext = &vs_stage;
|
||||
ps_stage.shader.stage = XGL_SHADER_STAGE_FRAGMENT;
|
||||
ps_stage.shader.shader = *ps;
|
||||
ps_stage.shader.shader = ps;
|
||||
|
||||
const int slots = 1;
|
||||
XGL_DESCRIPTOR_SLOT_INFO *slotInfo = (XGL_DESCRIPTOR_SLOT_INFO*) malloc( slots * sizeof(XGL_DESCRIPTOR_SLOT_INFO) );
|
||||
@ -473,11 +431,11 @@ void XglRenderFramework::CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADE
|
||||
ASSERT_XGL_SUCCESS(err);
|
||||
}
|
||||
|
||||
void XglRenderFramework::GenerateBindRenderTargetCmd(XglImage *renderTarget)
|
||||
void XglRenderFramework::GenerateBindRenderTargetCmd()
|
||||
{
|
||||
// bind render target
|
||||
XGL_COLOR_ATTACHMENT_BIND_INFO colorBind = {};
|
||||
colorBind.view = renderTarget->targetView();
|
||||
colorBind.view = m_renderTarget->targetView();
|
||||
colorBind.colorAttachmentState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL;
|
||||
xglCmdBindAttachments(m_cmdBuffer, 1, &colorBind, NULL );
|
||||
}
|
||||
@ -493,9 +451,12 @@ void XglRenderFramework::GenerateBindStateAndPipelineCmds(XGL_PIPELINE* pipeline
|
||||
|
||||
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view)
|
||||
xglCmdBindPipeline( m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, *pipeline );
|
||||
|
||||
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view)
|
||||
xglCmdBindDescriptorSet(m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 );
|
||||
}
|
||||
|
||||
void XglRenderFramework::GenerateClearAndPrepareBufferCmds(XglImage *renderTarget)
|
||||
void XglRenderFramework::GenerateClearAndPrepareBufferCmds()
|
||||
{
|
||||
// whatever we want to do, we do it to the whole buffer
|
||||
XGL_IMAGE_SUBRESOURCE_RANGE srRange = {};
|
||||
@ -526,20 +487,4 @@ void XglRenderFramework::GenerateClearAndPrepareBufferCmds(XglImage *renderTarge
|
||||
transitionToRender.subresourceRange = srRange;
|
||||
xglCmdPrepareImages( m_cmdBuffer, 1, &transitionToRender );
|
||||
m_renderTarget->state(( XGL_IMAGE_STATE ) transitionToClear.newState);
|
||||
|
||||
// bind render target
|
||||
XGL_COLOR_ATTACHMENT_BIND_INFO colorBind = {};
|
||||
colorBind.view = m_renderTarget->targetView();
|
||||
colorBind.colorAttachmentState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL;
|
||||
xglCmdBindAttachments(m_cmdBuffer, 1, &colorBind, NULL );
|
||||
|
||||
// set all states
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_RASTER, m_stateRaster );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_VIEWPORT, m_stateViewport );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_COLOR_BLEND, m_colorBlend);
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_DEPTH_STENCIL, m_stateDepthStencil );
|
||||
xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_MSAA, m_stateMsaa );
|
||||
|
||||
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view)
|
||||
xglCmdBindDescriptorSet(m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 );
|
||||
}
|
||||
|
@ -46,13 +46,14 @@ public:
|
||||
void InitMesh( XGL_UINT32 numVertices, XGL_GPU_SIZE vbStride, const void* vertices );
|
||||
void InitConstantBuffer( int constantCount, int constantSize, const void* data );
|
||||
void InitViewport(float width, float height);
|
||||
void InitViewport();
|
||||
void InitRenderTarget();
|
||||
void InitFramework();
|
||||
void ShutdownFramework();
|
||||
void InitState();
|
||||
void CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADER* vs, XGL_SHADER* ps);
|
||||
void GenerateClearAndPrepareBufferCmds(XglImage *renderTarget);
|
||||
void GenerateBindRenderTargetCmd(XglImage *renderTarget);
|
||||
void CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADER vs, XGL_SHADER ps);
|
||||
void GenerateClearAndPrepareBufferCmds();
|
||||
void GenerateBindRenderTargetCmd();
|
||||
void GenerateBindStateAndPipelineCmds(XGL_PIPELINE* pipeline);
|
||||
|
||||
protected:
|
||||
|
@ -87,7 +87,6 @@ void TestEnvironment::TearDown()
|
||||
}
|
||||
|
||||
XglTestFramework::XglTestFramework() :
|
||||
m_glut_initialized( false ),
|
||||
m_compile_options( 0 ),
|
||||
m_num_shader_strings( 0 )
|
||||
{
|
||||
@ -105,6 +104,7 @@ bool XglTestFramework::m_save_images = false;
|
||||
int XglTestFramework::m_width = 0;
|
||||
int XglTestFramework::m_height = 0;
|
||||
int XglTestFramework::m_window = 0;
|
||||
bool XglTestFramework::m_glut_initialized = false;
|
||||
std::list<XglTestImageRecord> XglTestFramework::m_images;
|
||||
std::list<XglTestImageRecord>::iterator XglTestFramework::m_display_image;
|
||||
int m_display_image_idx = 0;
|
||||
@ -165,7 +165,7 @@ void XglTestFramework::WritePPM( const char *basename, XglImage *image )
|
||||
{
|
||||
string filename;
|
||||
XGL_RESULT err;
|
||||
int x, y;
|
||||
int x, y;
|
||||
|
||||
filename.append(basename);
|
||||
filename.append(".ppm");
|
||||
@ -267,7 +267,8 @@ void XglTestFramework::Show(const char *comment, XglImage *image)
|
||||
m_images.push_back(record);
|
||||
m_display_image = --m_images.end();
|
||||
|
||||
Display();
|
||||
// Display();
|
||||
glutPostRedisplay();
|
||||
|
||||
err = image->UnmapMemory();
|
||||
ASSERT_XGL_SUCCESS( err );
|
||||
@ -279,11 +280,11 @@ void XglTestFramework::RecordImage(XglImage *image)
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
|
||||
if (m_save_images) {
|
||||
WritePPM(test_info->test_case_name(), image);
|
||||
WritePPM(test_info->name(), image);
|
||||
}
|
||||
|
||||
if (m_show_images) {
|
||||
Show(test_info->test_case_name(), image);
|
||||
Show(test_info->name(), image);
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,6 +348,7 @@ void XglTestFramework::Finish()
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
glutDisplayFunc( Display );
|
||||
glutIdleFunc(NULL);
|
||||
|
||||
glutMainLoop();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ private:
|
||||
static std::list<XglTestImageRecord>::iterator m_display_image;
|
||||
static int m_display_image_idx;
|
||||
|
||||
bool m_glut_initialized;
|
||||
static bool m_glut_initialized;
|
||||
static int m_window;
|
||||
static int m_width; // Window width
|
||||
static int m_height; // Window height
|
||||
|
Loading…
x
Reference in New Issue
Block a user