| 106 | #endif |
| 107 | |
| 108 | bool GPUPipelineState::Init(const Description& desc) |
| 109 | { |
| 110 | // Cache description in development builds |
| 111 | #if !BUILD_RELEASE |
| 112 | DebugDesc = desc; |
| 113 | #endif |
| 114 | |
| 115 | // Cache shader stages usage flags for pipeline state |
| 116 | Platform::MemoryClear(&_meta, sizeof(_meta)); |
| 117 | #define CHECK_STAGE(stage) \ |
| 118 | if (desc.stage) { \ |
| 119 | _meta.UsedCBsMask |= desc.stage->GetBindings().UsedCBsMask; \ |
| 120 | _meta.UsedSRsMask |= desc.stage->GetBindings().UsedSRsMask; \ |
| 121 | _meta.UsedUAsMask |= desc.stage->GetBindings().UsedUAsMask; \ |
| 122 | _meta.UsedSamplersMask |= desc.stage->GetBindings().UsedSamplersMask; \ |
| 123 | } |
| 124 | CHECK_STAGE(VS); |
| 125 | CHECK_STAGE(HS); |
| 126 | CHECK_STAGE(DS); |
| 127 | CHECK_STAGE(GS); |
| 128 | CHECK_STAGE(PS); |
| 129 | #undef CHECK_STAGE |
| 130 | |
| 131 | #if USE_EDITOR |
| 132 | // Estimate somehow performance cost of this pipeline state for the content profiling |
| 133 | const int32 textureLookupCost = 20; |
| 134 | const int32 tessCost = 300; |
| 135 | Complexity = Utilities::CountBits(_meta.UsedSRsMask) * textureLookupCost; |
| 136 | if (desc.PS) |
| 137 | Complexity += desc.PS->GetBindings().InstructionsCount; |
| 138 | if (desc.HS || desc.DS) |
| 139 | Complexity += tessCost; |
| 140 | if (desc.DepthWriteEnable) |
| 141 | Complexity += 5; |
| 142 | if (desc.DepthEnable) |
| 143 | Complexity += 5; |
| 144 | if (desc.BlendMode.BlendEnable) |
| 145 | Complexity += 20; |
| 146 | #endif |
| 147 | |
| 148 | return false; |
| 149 | } |
| 150 | |
| 151 | GPUResourceType GPUPipelineState::GetResourceType() const |
| 152 | { |
no test coverage detected