| 1229 | } |
| 1230 | |
| 1231 | static HRenderTarget NullNewRenderTarget(HContext _context, uint32_t buffer_type_flags, const RenderTargetCreationParams params) |
| 1232 | { |
| 1233 | NullContext* context = (NullContext*) _context; |
| 1234 | NullRenderTarget* rt = new NullRenderTarget(); |
| 1235 | |
| 1236 | BufferType color_buffer_flags[] = { |
| 1237 | BUFFER_TYPE_COLOR0_BIT, |
| 1238 | BUFFER_TYPE_COLOR1_BIT, |
| 1239 | BUFFER_TYPE_COLOR2_BIT, |
| 1240 | BUFFER_TYPE_COLOR3_BIT, |
| 1241 | }; |
| 1242 | |
| 1243 | void** color_buffers[MAX_BUFFER_COLOR_ATTACHMENTS] = { |
| 1244 | &rt->m_FrameBuffer.m_ColorBuffer[0], |
| 1245 | &rt->m_FrameBuffer.m_ColorBuffer[1], |
| 1246 | &rt->m_FrameBuffer.m_ColorBuffer[2], |
| 1247 | &rt->m_FrameBuffer.m_ColorBuffer[3] |
| 1248 | }; |
| 1249 | |
| 1250 | uint32_t* color_buffer_sizes[MAX_BUFFER_COLOR_ATTACHMENTS] = { |
| 1251 | &rt->m_FrameBuffer.m_ColorBufferSize[0], |
| 1252 | &rt->m_FrameBuffer.m_ColorBufferSize[1], |
| 1253 | &rt->m_FrameBuffer.m_ColorBufferSize[2], |
| 1254 | &rt->m_FrameBuffer.m_ColorBufferSize[3] |
| 1255 | }; |
| 1256 | |
| 1257 | DM_MUTEX_OPTIONAL_SCOPED_LOCK(g_NullContext->m_BaseContext.m_AssetHandleContainerMutex); |
| 1258 | uint8_t color_attachment_count = 0; |
| 1259 | for (int i = 0; i < MAX_BUFFER_COLOR_ATTACHMENTS; ++i) |
| 1260 | { |
| 1261 | if (buffer_type_flags & color_buffer_flags[i]) |
| 1262 | { |
| 1263 | rt->m_Base.m_ColorTextureParams[i] = params.m_ColorBufferParams[i]; |
| 1264 | ClearTextureParamsData(rt->m_Base.m_ColorTextureParams[i]); |
| 1265 | uint32_t buffer_size = GetBufferSize(params.m_ColorBufferParams[i]); |
| 1266 | rt->m_Base.m_ColorTextureParams[i].m_DataSize = buffer_size; |
| 1267 | rt->m_Base.m_TextureColor[i] = NewTexture(_context, params.m_ColorBufferCreationParams[i]); |
| 1268 | NullTexture* attachment_tex = 0x0; |
| 1269 | { |
| 1270 | attachment_tex = GetAssetFromContainer<NullTexture>(context->m_BaseContext.m_AssetHandleContainer, rt->m_Base.m_TextureColor[i]); |
| 1271 | } |
| 1272 | SetTexture(_context, rt->m_Base.m_TextureColor[i], rt->m_Base.m_ColorTextureParams[i]); |
| 1273 | *(color_buffer_sizes[i]) = buffer_size; |
| 1274 | *(color_buffers[i]) = attachment_tex->m_Data; |
| 1275 | ++color_attachment_count; |
| 1276 | } |
| 1277 | } |
| 1278 | rt->m_Base.m_ColorAttachmentCount = color_attachment_count; |
| 1279 | |
| 1280 | if (buffer_type_flags & BUFFER_TYPE_DEPTH_BIT) |
| 1281 | { |
| 1282 | rt->m_Base.m_DepthBufferParams = params.m_DepthBufferParams; |
| 1283 | ClearTextureParamsData(rt->m_Base.m_DepthBufferParams); |
| 1284 | if (params.m_DepthTexture) |
| 1285 | { |
| 1286 | uint32_t buffer_size = sizeof(float) * params.m_DepthBufferParams.m_Width * params.m_DepthBufferParams.m_Height; |
| 1287 | rt->m_Base.m_DepthBufferParams.m_DataSize = buffer_size; |
| 1288 | rt->m_Base.m_TextureDepth = NewTexture(_context, params.m_DepthBufferCreationParams); |
nothing calls this directly
no test coverage detected