Add reflection for fragment inputs/outputs from Tint
BUG=dawn:702 Change-Id: I1a75929bbb91411c10dac5a5408e8fc57d67102b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44460 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
798dea1d94
commit
bdc1340449
|
@ -174,6 +174,23 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultOrError<wgpu::TextureComponentType> TintComponentTypeToTextureComponentType(
|
||||||
|
tint::inspector::ComponentType type) {
|
||||||
|
switch (type) {
|
||||||
|
case tint::inspector::ComponentType::kFloat:
|
||||||
|
return wgpu::TextureComponentType::Float;
|
||||||
|
case tint::inspector::ComponentType::kSInt:
|
||||||
|
return wgpu::TextureComponentType::Sint;
|
||||||
|
case tint::inspector::ComponentType::kUInt:
|
||||||
|
return wgpu::TextureComponentType::Uint;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Attempted to convert unexpected component type from Tint");
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DAWN_ENABLE_WGSL
|
#endif // DAWN_ENABLE_WGSL
|
||||||
|
|
||||||
MaybeError ValidateSpirv(const uint32_t* code, uint32_t codeSize) {
|
MaybeError ValidateSpirv(const uint32_t* code, uint32_t codeSize) {
|
||||||
|
@ -781,6 +798,35 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (metadata->stage == SingleShaderStage::Fragment) {
|
||||||
|
for (const auto& input_var : entryPoint.input_variables) {
|
||||||
|
if (!input_var.has_location_decoration) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Need location decoration on fragment input");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& output_var : entryPoint.output_variables) {
|
||||||
|
if (!output_var.has_location_decoration) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Need location decoration on fragment output");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t unsanitizedAttachment = output_var.location_decoration;
|
||||||
|
if (unsanitizedAttachment >= kMaxColorAttachments) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Fragment output index must be less than max number of color "
|
||||||
|
"attachments");
|
||||||
|
}
|
||||||
|
ColorAttachmentIndex attachment(
|
||||||
|
static_cast<uint8_t>(unsanitizedAttachment));
|
||||||
|
DAWN_TRY_ASSIGN(
|
||||||
|
metadata->fragmentOutputFormatBaseTypes[attachment],
|
||||||
|
TintComponentTypeToTextureComponentType(output_var.component_type));
|
||||||
|
metadata->fragmentOutputsWritten.set(attachment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result[entryPoint.name] = std::move(metadata);
|
result[entryPoint.name] = std::move(metadata);
|
||||||
}
|
}
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
|
@ -866,11 +912,20 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tintEntry->stage == SingleShaderStage::Fragment) {
|
||||||
|
// Equality is explictly not being tested, since SPIRV-Cross will include unused
|
||||||
|
// variables in the written bitset. Instead testing that Tint's bitset is
|
||||||
|
// a subset of SPIRV-Cross's.
|
||||||
|
if (tintEntry->fragmentOutputsWritten !=
|
||||||
|
(tintEntry->fragmentOutputsWritten & crossEntry->fragmentOutputsWritten)) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Tint and SPIRV-Cross returned different values for used fragment "
|
||||||
|
"output base type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(rharrison): Use the Inspector to get this data.
|
// TODO(rharrison): Use the Inspector to get this data.
|
||||||
tintEntry->bindings = crossEntry->bindings;
|
tintEntry->bindings = crossEntry->bindings;
|
||||||
tintEntry->fragmentOutputFormatBaseTypes =
|
|
||||||
crossEntry->fragmentOutputFormatBaseTypes;
|
|
||||||
tintEntry->fragmentOutputsWritten = crossEntry->fragmentOutputsWritten;
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue