rendering: add vulkan hlsl shader compilation
This commit is contained in:
@@ -53,6 +53,46 @@ void main() {
|
||||
delete pipelineState;
|
||||
}
|
||||
|
||||
TEST_F(VulkanGraphicsFixture, CreateGraphicsPipelineFromHlslShadersProducesValidPipeline) {
|
||||
static const char* vertexSource = R"(
|
||||
float4 MainVS(uint vertexId : SV_VertexID) : SV_POSITION
|
||||
{
|
||||
const float x = (vertexId == 1u) ? 0.5f : -0.5f;
|
||||
const float y = (vertexId == 2u) ? -0.5f : 0.5f;
|
||||
return float4(x, y, 0.0f, 1.0f);
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* fragmentSource = R"(
|
||||
float4 MainPS() : SV_TARGET
|
||||
{
|
||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
)";
|
||||
|
||||
GraphicsPipelineDesc pipelineDesc = {};
|
||||
pipelineDesc.topologyType = static_cast<uint32_t>(PrimitiveTopologyType::Triangle);
|
||||
pipelineDesc.renderTargetFormats[0] = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
||||
pipelineDesc.depthStencilFormat = static_cast<uint32_t>(Format::Unknown);
|
||||
|
||||
pipelineDesc.vertexShader.sourceLanguage = ShaderLanguage::HLSL;
|
||||
pipelineDesc.vertexShader.entryPoint = L"MainVS";
|
||||
pipelineDesc.vertexShader.profile = L"vs_5_0";
|
||||
pipelineDesc.vertexShader.source.assign(vertexSource, vertexSource + std::strlen(vertexSource));
|
||||
|
||||
pipelineDesc.fragmentShader.sourceLanguage = ShaderLanguage::HLSL;
|
||||
pipelineDesc.fragmentShader.entryPoint = L"MainPS";
|
||||
pipelineDesc.fragmentShader.profile = L"ps_5_0";
|
||||
pipelineDesc.fragmentShader.source.assign(fragmentSource, fragmentSource + std::strlen(fragmentSource));
|
||||
|
||||
RHIPipelineState* pipelineState = m_device->CreatePipelineState(pipelineDesc);
|
||||
ASSERT_NE(pipelineState, nullptr);
|
||||
EXPECT_TRUE(pipelineState->IsValid());
|
||||
EXPECT_NE(pipelineState->GetNativeHandle(), nullptr);
|
||||
pipelineState->Shutdown();
|
||||
delete pipelineState;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user