| 74 | } |
| 75 | |
| 76 | int32_t Tr2RenderTarget::Create( |
| 77 | unsigned width, |
| 78 | unsigned height, |
| 79 | unsigned mipLevelCount, |
| 80 | Tr2RenderContextEnum::PixelFormat format, |
| 81 | unsigned msaaType, |
| 82 | unsigned msaaQuality, |
| 83 | Tr2RenderContextEnum::ExFlag flags, |
| 84 | Tr2RenderContextEnum::TextureType type ) |
| 85 | { |
| 86 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 87 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 88 | if( IsAttached() ) |
| 89 | { |
| 90 | return E_INVALIDARG; |
| 91 | } |
| 92 | |
| 93 | auto gpuUsage = Tr2GpuUsage::NONE; |
| 94 | auto cpuUsage = Tr2CpuUsage::NONE; |
| 95 | GetUsage( uint32_t( msaaType ), flags, gpuUsage, cpuUsage ); |
| 96 | if( !type ) |
| 97 | { |
| 98 | type = TEX_TYPE_2D; |
| 99 | } |
| 100 | |
| 101 | auto hr = m_renderTarget.Create( |
| 102 | Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount ), |
| 103 | Tr2MsaaDesc( msaaType, msaaQuality ), |
| 104 | gpuUsage, |
| 105 | cpuUsage, |
| 106 | nullptr, |
| 107 | renderContext ) |
| 108 | .GetResult(); |
| 109 | if( SUCCEEDED( hr ) ) |
| 110 | { |
| 111 | m_width = width; |
| 112 | m_height = height; |
| 113 | m_arraySize = 1; |
| 114 | m_mipCount = mipLevelCount; |
| 115 | m_format = format; |
| 116 | m_msaa = Tr2MsaaDesc( msaaType, msaaQuality ); |
| 117 | m_flags = ExFlag( flags ); |
| 118 | m_type = type; |
| 119 | m_cpuUsage = cpuUsage; |
| 120 | m_gpuUsage = gpuUsage; |
| 121 | m_renderTarget.SetName( m_name.c_str() ); |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | Destroy(); |
| 126 | } |
| 127 | return hr; |
| 128 | } |
| 129 | |
| 130 | int32_t Tr2RenderTarget::CreateArray( |
| 131 | unsigned width, |