[spirv] Support for post_depth_coverage extension. (#1461)

This commit is contained in:
Ehsan 2018-07-27 17:16:41 -04:00 коммит произвёл GitHub
Родитель ba6eb6f2ef
Коммит f9882c84a7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -261,6 +261,8 @@ The namespace ``vk`` will be used for all Vulkan attributes:
and struct fields.
- ``index(X)``: For specifying the index at a specific pixel shader output
location. Used for dual-source blending.
- ``post_depth_coverage``: The input variable decorated with SampleMask will
reflect the result of the EarlyFragmentTests. Only valid on pixel shader entry points.
Only ``vk::`` attributes in the above list are supported. Other attributes will
result in warnings and be ignored by the compiler. All C++11 attributes will

Просмотреть файл

@ -961,6 +961,13 @@ def VKConstantId : InheritableAttr {
let Documentation = [Undocumented];
}
def VKPostDepthCoverage : InheritableAttr {
let Spellings = [CXX11<"vk", "post_depth_coverage">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let LangOpts = [SPIRV];
let Documentation = [Undocumented];
}
// SPIRV Change Ends
def C11NoReturn : InheritableAttr {

Просмотреть файл

@ -34,6 +34,7 @@ enum class Extension {
KHR_device_group,
KHR_multiview,
KHR_shader_draw_parameters,
KHR_post_depth_coverage,
EXT_descriptor_indexing,
EXT_fragment_fully_covered,
EXT_shader_stencil_export,

Просмотреть файл

@ -113,6 +113,8 @@ Extension FeatureManager::getExtensionSymbol(llvm::StringRef name) {
Extension::AMD_shader_explicit_vertex_parameter)
.Case("SPV_GOOGLE_hlsl_functionality1",
Extension::GOOGLE_hlsl_functionality1)
.Case("SPV_KHR_post_depth_coverage",
Extension::KHR_post_depth_coverage)
.Default(Extension::Unknown);
}
@ -128,6 +130,8 @@ const char *FeatureManager::getExtensionName(Extension symbol) {
return "SPV_KHR_multiview";
case Extension::KHR_shader_draw_parameters:
return "SPV_KHR_shader_draw_parameters";
case Extension::KHR_post_depth_coverage:
return "SPV_KHR_post_depth_coverage";
case Extension::EXT_descriptor_indexing:
return "SPV_EXT_descriptor_indexing";
case Extension::EXT_fragment_fully_covered:

Просмотреть файл

@ -9233,6 +9233,13 @@ void SPIRVEmitter::processPixelShaderAttributes(const FunctionDecl *decl) {
theBuilder.addExecutionMode(entryFunctionId,
spv::ExecutionMode::EarlyFragmentTests, {});
}
if (decl->getAttr<VKPostDepthCoverageAttr>()) {
theBuilder.addExtension(Extension::KHR_post_depth_coverage,
"[[vk::post_depth_coverage]]", decl->getLocation());
theBuilder.requireCapability(spv::Capability::SampleMaskPostDepthCoverage);
theBuilder.addExecutionMode(entryFunctionId,
spv::ExecutionMode::PostDepthCoverage, {});
}
}
void SPIRVEmitter::processComputeShaderAttributes(const FunctionDecl *decl) {

Просмотреть файл

@ -10552,6 +10552,9 @@ void hlsl::HandleDeclAttributeForHLSL(Sema &S, Decl *D, const AttributeList &A,
declAttr = ::new (S.Context) VKConstantIdAttr(A.getRange(), S.Context,
ValidateAttributeIntArg(S, A), A.getAttributeSpellingListIndex());
break;
case AttributeList::AT_VKPostDepthCoverage:
declAttr = ::new (S.Context) VKPostDepthCoverageAttr(A.getRange(), S.Context, A.getAttributeSpellingListIndex());
break;
default:
Handled = false;
return;

Просмотреть файл

@ -0,0 +1,8 @@
// Run: %dxc -T ps_6_0 -E main
// CHECK: OpCapability SampleMaskPostDepthCoverage
// CHECK: OpExtension "SPV_KHR_post_depth_coverage"
// CHECK: OpExecutionMode %main PostDepthCoverage
[[vk::post_depth_coverage]]
float4 main() : SV_Target { return 1.0; }

Просмотреть файл

@ -1008,6 +1008,9 @@ TEST_F(FileTest, IntrinsicsNonUniformResourceIndex) {
TEST_F(FileTest, AttributeEarlyDepthStencil) {
runFileTest("attribute.earlydepthstencil.ps.hlsl");
}
TEST_F(FileTest, AttributePostDepthCoverage) {
runFileTest("attribute.postdepthcoverage.ps.hlsl");
}
TEST_F(FileTest, AttributeNumThreads) {
runFileTest("attribute.numthreads.hlsl");
}