From c9d94248dc73fe41c344b0a23230e597f7b94a2c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 13 Nov 2017 14:17:09 -0800 Subject: Parameter block work (#276) * Don't auto-enable IR use for compute tests The `COMPARE_COMPUTE` and `COMPARE_RENDER_COMPUTE` test fixtures were set up to always enable the `-use-ir` flag on Slang, which precludes having any tests that confirm functionality on the old non-IR path (which is still required by our main customer). This change adds the `-xslang -use-ir` flags explicitly to any compute test cases that left them out, and makes the fixture no longer add it by default. * Continue building out parameter block support The initial front-end logic for parameter blocks was already added, but they are still missing a bunch of functionality. This change addresses some of the known issues: - Bug fix: don't try to emit HLSL `register` bindings for variables that consume whole register spaces/sets - Overhaul type layout logic so that it can make decisions based on a given code generation target (currently passed in as a `TargetRequest`), which allows us to decide whether or not a parameter block should get its own register set on a per-target basis. - Always use a register space/set for Vulkan - Never use a register space/set for HLSL SM 5.0 and lower - By default, don't use register spaces/sets for HLSL output - Add a command-line flag and some "target flags" to enable register-space usage for D3D targets - Hackily add initial support for parameter blocks in the AST-to-AST path - This just blindly lowers `ParameterBlock` to `T`, which shouldn't quite work - A more complete overhaul will probably need to wait until the AST-to-AST legalization is changed to use the `LegalType`s from the IR legalization pass. - Add a compute-based test case to actually run code using parameter blocks - This file runs test cases both with and without the IR --- source/slang/ir-legalize-types.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'source/slang/ir-legalize-types.cpp') diff --git a/source/slang/ir-legalize-types.cpp b/source/slang/ir-legalize-types.cpp index 5b42407c2..5b08acee8 100644 --- a/source/slang/ir-legalize-types.cpp +++ b/source/slang/ir-legalize-types.cpp @@ -660,13 +660,13 @@ static LegalVal declareSimpleVar( // those to all the nested resource infos. for (auto vv = varChain; vv; vv = vv->next) { - auto parentSpaceInfo = vv->varLayout->findOrAddResourceInfo(LayoutResourceKind::ParameterBlock); + auto parentSpaceInfo = vv->varLayout->findOrAddResourceInfo(LayoutResourceKind::RegisterSpace); if (!parentSpaceInfo) continue; for (auto& rr : varLayout->resourceInfos) { - if (rr.kind == LayoutResourceKind::ParameterBlock) + if (rr.kind == LayoutResourceKind::RegisterSpace) { rr.index += parentSpaceInfo->index; } @@ -827,21 +827,13 @@ static void legalizeGlobalVar( RefPtr varLayout = findVarLayout(irGlobalVar); RefPtr typeLayout = varLayout ? varLayout->typeLayout : nullptr; - // If we've decided to do implicit deref on the type, - // then go ahead and declare a value of the pointed-to type. - LegalType maybeSimpleType = legalValueType; - while (maybeSimpleType.flavor == LegalType::Flavor::implicitDeref) - { - maybeSimpleType = maybeSimpleType.getImplicitDeref()->valueType; - } - - switch (maybeSimpleType.flavor) + switch (legalValueType.flavor) { case LegalType::Flavor::simple: // Easy case: the type is usable as-is, and we // should just do that. irGlobalVar->type = context->session->getPtrType( - maybeSimpleType.getSimple()); + legalValueType.getSimple()); break; default: -- cgit v1.2.3