| 1073 | } |
| 1074 | |
| 1075 | std::unique_ptr<EI_PSO> EI_Device::CreateGraphicsPSO(const char* vertexShaderName, const char* vertexEntryPoint, const char* fragmentShaderName, const char* fragmentEntryPoint, EI_PSOParams& psoParams) |
| 1076 | { |
| 1077 | EI_PSO* result = new EI_PSO; |
| 1078 | |
| 1079 | DefineList defines; |
| 1080 | defines["AMD_TRESSFX_MAX_NUM_BONES"] = std::to_string(AMD_TRESSFX_MAX_NUM_BONES); |
| 1081 | defines["AMD_TRESSFX_MAX_HAIR_GROUP_RENDER"] = std::to_string(AMD_TRESSFX_MAX_HAIR_GROUP_RENDER); |
| 1082 | defines["AMD_TRESSFX_DX12"] = "1"; |
| 1083 | |
| 1084 | #ifdef TRESSFX_DEBUG_UAV |
| 1085 | defines["TRESSFX_DEBUG_UAV"] = "1"; |
| 1086 | #endif // TRESSFX_DEBUG_UAV |
| 1087 | |
| 1088 | // Compile and create shaders |
| 1089 | D3D12_SHADER_BYTECODE vertexShader, fragmentShader; |
| 1090 | |
| 1091 | CAULDRON_DX12::CompileShaderFromFile(vertexShaderName, &defines, vertexEntryPoint, "vs_6_0", D3DCOMPILE_DEBUG | D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_SKIP_OPTIMIZATION, &vertexShader); |
| 1092 | CAULDRON_DX12::CompileShaderFromFile(fragmentShaderName, &defines, fragmentEntryPoint, "ps_6_0", D3DCOMPILE_DEBUG | D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_SKIP_OPTIMIZATION, &fragmentShader); |
| 1093 | |
| 1094 | CD3DX12_ROOT_PARAMETER descSetLayouts[16]; |
| 1095 | for (int i = 0; i < psoParams.numLayouts; ++i) |
| 1096 | { |
| 1097 | // i dont like this since it has a side effect on the layout that gets passed - i'd just get rid of the spaces |
| 1098 | for (int j = 0; j < psoParams.layouts[i]->layoutBindings.size(); ++j) |
| 1099 | { |
| 1100 | psoParams.layouts[i]->layoutBindings[j].RegisterSpace = i; |
| 1101 | } |
| 1102 | descSetLayouts[i].InitAsDescriptorTable((uint32_t)psoParams.layouts[i]->layoutBindings.size(), psoParams.layouts[i]->layoutBindings.data(), GetShaderVisibility(psoParams.layouts[i]->description.stage)); |
| 1103 | } |
| 1104 | |
| 1105 | CD3DX12_ROOT_SIGNATURE_DESC descRootSignature = CD3DX12_ROOT_SIGNATURE_DESC(); |
| 1106 | descRootSignature.NumParameters = psoParams.numLayouts; |
| 1107 | descRootSignature.pParameters = descSetLayouts; |
| 1108 | descRootSignature.NumStaticSamplers = 0; |
| 1109 | descRootSignature.pStaticSamplers = 0; |
| 1110 | |
| 1111 | // deny uneccessary access to certain pipeline stages |
| 1112 | descRootSignature.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE |
| 1113 | | D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |
| 1114 | | D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS |
| 1115 | | D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS |
| 1116 | | D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS; |
| 1117 | |
| 1118 | ID3DBlob* signature; |
| 1119 | ID3DBlob* error; |
| 1120 | HRESULT hr = D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error); |
| 1121 | m_device.GetDevice()->CreateRootSignature( |
| 1122 | 0, |
| 1123 | signature->GetBufferPointer(), |
| 1124 | signature->GetBufferSize(), |
| 1125 | __uuidof(ID3D12RootSignature), |
| 1126 | (void**)&result->m_pipelineLayout); |
| 1127 | |
| 1128 | signature->Release(); |
| 1129 | if (error) |
| 1130 | error->Release(); |
| 1131 | |
| 1132 | // Setup blending |
nothing calls this directly
no test coverage detected