Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 1 | /* |
| 2 | * XGL Tests |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Courtney Goeltzenleuchter <courtney@lunarg.com> |
| 26 | */ |
| 27 | |
| 28 | #ifndef XGLRENDERFRAMEWORK_H |
| 29 | #define XGLRENDERFRAMEWORK_H |
| 30 | |
| 31 | #include "xgltestframework.h" |
| 32 | |
| 33 | class XglRenderFramework : public XglTestFramework |
| 34 | { |
| 35 | public: |
| 36 | XglRenderFramework(); |
| 37 | ~XglRenderFramework(); |
| 38 | |
| 39 | void CreateQueryPool(XGL_QUERY_TYPE type, XGL_UINT slots, |
| 40 | XGL_QUERY_POOL *pPool, XGL_GPU_MEMORY *pMem); |
| 41 | void DestroyQueryPool(XGL_QUERY_POOL pool, XGL_GPU_MEMORY mem); |
| 42 | |
| 43 | XGL_DEVICE device() {return m_device->device();} |
| 44 | void CreateShader(XGL_PIPELINE_SHADER_STAGE stage, const char *shader_code, XGL_SHADER *pshader); |
| 45 | void InitPipeline(); |
| 46 | void InitMesh( XGL_UINT32 numVertices, XGL_GPU_SIZE vbStride, const void* vertices ); |
| 47 | void InitConstantBuffer( int constantCount, int constantSize, const void* data ); |
| 48 | void InitViewport(float width, float height); |
| 49 | void InitRenderTarget(); |
| 50 | void InitFramework(); |
Courtney Goeltzenleuchter | cb5a89c | 2014-10-08 12:20:26 -0600 | [diff] [blame^] | 51 | void ShutdownFramework(); |
| 52 | void InitState(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 53 | void CreateDefaultPipeline(XGL_PIPELINE* pipeline, XGL_SHADER* vs, XGL_SHADER* ps); |
| 54 | void GenerateClearAndPrepareBufferCmds(XglImage *renderTarget); |
| 55 | void GenerateBindRenderTargetCmd(XglImage *renderTarget); |
| 56 | void GenerateBindStateAndPipelineCmds(XGL_PIPELINE* pipeline); |
| 57 | |
| 58 | protected: |
| 59 | XGL_APPLICATION_INFO app_info; |
| 60 | XGL_PHYSICAL_GPU objs[MAX_GPUS]; |
| 61 | XGL_UINT gpu_count; |
| 62 | XGL_GPU_MEMORY m_descriptor_set_mem; |
| 63 | XGL_GPU_MEMORY m_pipe_mem; |
| 64 | XglDevice *m_device; |
| 65 | XGL_CMD_BUFFER m_cmdBuffer; |
| 66 | XGL_UINT32 m_numVertices; |
| 67 | XGL_MEMORY_VIEW_ATTACH_INFO m_vtxBufferView; |
| 68 | XGL_MEMORY_VIEW_ATTACH_INFO m_constantBufferView; |
| 69 | XGL_GPU_MEMORY m_vtxBufferMem; |
| 70 | XGL_GPU_MEMORY m_constantBufferMem; |
| 71 | XGL_UINT32 m_numMemRefs; |
| 72 | XGL_MEMORY_REF m_memRefs[5]; |
| 73 | XGL_RASTER_STATE_OBJECT m_stateRaster; |
| 74 | XGL_COLOR_BLEND_STATE_OBJECT m_colorBlend; |
| 75 | XGL_VIEWPORT_STATE_OBJECT m_stateViewport; |
| 76 | XGL_DEPTH_STENCIL_STATE_OBJECT m_stateDepthStencil; |
| 77 | XGL_MSAA_STATE_OBJECT m_stateMsaa; |
| 78 | XGL_DESCRIPTOR_SET m_rsrcDescSet; |
| 79 | XglImage *m_renderTarget; |
| 80 | XGL_FLOAT m_width, m_height; |
| 81 | XGL_FORMAT m_render_target_fmt; |
| 82 | |
| 83 | /* |
| 84 | * SetUp and TearDown are called by the Google Test framework |
| 85 | * to initialize a test framework based on this class. |
| 86 | */ |
| 87 | virtual void SetUp() { |
| 88 | XGL_RESULT err; |
| 89 | |
| 90 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 91 | this->app_info.pNext = NULL; |
| 92 | this->app_info.pAppName = (const XGL_CHAR *) "base"; |
| 93 | this->app_info.appVersion = 1; |
| 94 | this->app_info.pEngineName = (const XGL_CHAR *) "unittest"; |
| 95 | this->app_info.engineVersion = 1; |
| 96 | this->app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0); |
| 97 | |
| 98 | memset(&m_vtxBufferView, 0, sizeof(m_vtxBufferView)); |
| 99 | m_vtxBufferView.sType = XGL_STRUCTURE_TYPE_MEMORY_VIEW_ATTACH_INFO; |
| 100 | |
| 101 | memset(&m_constantBufferView, 0, sizeof(m_constantBufferView)); |
| 102 | m_constantBufferView.sType = XGL_STRUCTURE_TYPE_MEMORY_VIEW_ATTACH_INFO; |
| 103 | |
| 104 | err = xglInitAndEnumerateGpus(&app_info, NULL, |
| 105 | MAX_GPUS, &this->gpu_count, objs); |
| 106 | ASSERT_XGL_SUCCESS(err); |
| 107 | ASSERT_GE(1, this->gpu_count) << "No GPU available"; |
| 108 | |
| 109 | m_device = new XglDevice(0, objs[0]); |
| 110 | m_device->get_device_queue(); |
| 111 | } |
| 112 | |
| 113 | virtual void TearDown() { |
| 114 | xglInitAndEnumerateGpus(&this->app_info, XGL_NULL_HANDLE, 0, &gpu_count, XGL_NULL_HANDLE); |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | #endif // XGLRENDERFRAMEWORK_H |