summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-12-06 12:05:07 -0800
committerGitHub <noreply@github.com>2023-12-06 12:05:07 -0800
commit11111e5733b189127dc2c4934d67693b9bc6e764 (patch)
tree0ba84df3e856eb104abec2ecac47242bc70a7b7d
parentfa6d8717d02912697c09f2d7de802723ac6d6e47 (diff)
Support visibility control and default to `internal`. (#3380)
* Support visibility control and default to `internal`. * Fix wip. * Fixes. * Fix. * Fix test. * Add legacy language detection and compatibility for existing code. * Add doc. --------- Co-authored-by: Yong He <yhe@nvidia.com>
-rw-r--r--docs/user-guide/04-modules-and-access-control.md169
-rw-r--r--docs/user-guide/05-interfaces-generics.md (renamed from docs/user-guide/04-interfaces-generics.md)0
-rw-r--r--docs/user-guide/06-compiling.md (renamed from docs/user-guide/05-compiling.md)0
-rw-r--r--docs/user-guide/07-targets.md (renamed from docs/user-guide/06-targets.md)0
-rw-r--r--docs/user-guide/08-autodiff.md (renamed from docs/user-guide/07-autodiff.md)0
-rw-r--r--docs/user-guide/toc.html72
-rw-r--r--examples/cpu-com-example/shader.slang8
-rw-r--r--source/slang/diff.meta.slang2
-rw-r--r--source/slang/glsl.meta.slang394
-rw-r--r--source/slang/slang-ast-decl.h9
-rw-r--r--source/slang/slang-ast-modifier.h5
-rw-r--r--source/slang/slang-ast-support-types.h8
-rw-r--r--source/slang/slang-check-conversion.cpp2
-rw-r--r--source/slang/slang-check-decl.cpp100
-rw-r--r--source/slang/slang-check-expr.cpp463
-rw-r--r--source/slang/slang-check-impl.h54
-rw-r--r--source/slang/slang-check-modifier.cpp84
-rw-r--r--source/slang/slang-check-overload.cpp62
-rw-r--r--source/slang/slang-diagnostic-defs.h9
-rw-r--r--source/slang/slang-emit-c-like.cpp4
-rw-r--r--source/slang/slang-ir-autodiff.cpp5
-rw-r--r--source/slang/slang-ir-dll-export.cpp6
-rw-r--r--source/slang/slang-ir-generics-lowering-context.cpp9
-rw-r--r--source/slang/slang-ir-link.cpp9
-rw-r--r--source/slang/slang-ir-lower-generic-type.cpp4
-rw-r--r--source/slang/slang-ir-pytorch-cpp-binding.cpp10
-rw-r--r--source/slang/slang-language-server-completion.cpp2
-rw-r--r--source/slang/slang-lookup.cpp16
-rw-r--r--source/slang/slang-lookup.h5
-rw-r--r--source/slang/slang-lower-to-ir.cpp41
-rw-r--r--source/slang/slang-parser.cpp29
-rw-r--r--source/slang/slang-syntax.cpp11
-rw-r--r--source/slang/slang-syntax.h1
-rw-r--r--tests/autodiff/bsdf/bsdf-auto-rev.slang3
-rw-r--r--tests/autodiff/bsdf/bsdf-sample.slang5
-rw-r--r--tests/autodiff/cuda-kernel-export.slang2
-rw-r--r--tests/autodiff/material/DiffuseMaterial.slang8
-rw-r--r--tests/autodiff/material/DiffuseMaterialInstance.slang12
-rw-r--r--tests/autodiff/material/GlossyMaterial.slang8
-rw-r--r--tests/autodiff/material/GlossyMaterialInstance.slang18
-rw-r--r--tests/autodiff/material/IBSDF.slang4
-rw-r--r--tests/autodiff/material/IMaterial.slang6
-rw-r--r--tests/autodiff/material/IMaterialInstance.slang4
-rw-r--r--tests/autodiff/material/MaterialSystem.slang2
-rw-r--r--tests/autodiff/material2/DiffuseMaterial.slang10
-rw-r--r--tests/autodiff/material2/DiffuseMaterialInstance.slang6
-rw-r--r--tests/autodiff/material2/GlossyMaterial.slang14
-rw-r--r--tests/autodiff/material2/GlossyMaterialInstance.slang6
-rw-r--r--tests/autodiff/material2/IBSDF.slang8
-rw-r--r--tests/autodiff/material2/IMaterial.slang6
-rw-r--r--tests/autodiff/material2/IMaterialInstance.slang8
-rw-r--r--tests/autodiff/material2/MaterialSystem.slang2
-rw-r--r--tests/autodiff/material2/MxLayeredMaterial.slang32
-rw-r--r--tests/autodiff/material2/MxLayeredMaterialInstance.slang12
-rw-r--r--tests/autodiff/material2/MxWeights.slang14
-rw-r--r--tests/bindings/multi-file-defines.h3
-rw-r--r--tests/bindings/multi-file-shared.slang28
-rw-r--r--tests/bugs/gl-33-ext.slang6
-rw-r--r--tests/bugs/interface-lvalue.slang2
-rw-r--r--tests/bugs/split-nested-types.slang14
-rw-r--r--tests/compute/array-existential-parameter.slang2
-rw-r--r--tests/compute/dynamic-dispatch-11.slang2
-rw-r--r--tests/compute/dynamic-dispatch-12.slang8
-rw-r--r--tests/compute/dynamic-dispatch-13.slang4
-rw-r--r--tests/compute/dynamic-dispatch-14.slang10
-rw-r--r--tests/compute/dynamic-dispatch-15.slang10
-rw-r--r--tests/compute/dynamic-dispatch-bindless-texture.slang2
-rw-r--r--tests/compute/interface-assoc-type-param.slang4
-rw-r--r--tests/compute/interface-func-param-in-struct.slang4
-rw-r--r--tests/compute/interface-param-partial-specialize.slang4
-rw-r--r--tests/cpu-program/class-com.slang6
-rw-r--r--tests/cpu-program/class.slang4
-rw-r--r--tests/cpu-program/cpu-hello-world.slang2
-rw-r--r--tests/cpu-program/gfx-smoke.slang4
-rw-r--r--tests/cpu-program/pointer-basics.slang4
-rw-r--r--tests/cpu-program/pointer-deref.slang4
-rw-r--r--tests/current-bugs/resource-dynamic-dispatch.slang6
-rw-r--r--tests/diagnostics/extension-visibility-a.slang12
-rw-r--r--tests/diagnostics/extension-visibility-b.slang4
-rw-r--r--tests/diagnostics/extension-visibility-c.slang2
-rw-r--r--tests/diagnostics/extension-visibility.slang.expected6
-rw-r--r--tests/diagnostics/internal-visibility/that-module-impl.slang17
-rw-r--r--tests/diagnostics/internal-visibility/that-module.slang25
-rw-r--r--tests/diagnostics/internal-visibility/this-module.slang26
-rw-r--r--tests/diagnostics/private-visibility.slang44
-rw-r--r--tests/diagnostics/visibility.slang23
-rw-r--r--tests/front-end/import-exported-b.slang2
-rw-r--r--tests/front-end/import-subdir-search-path.slang2
-rw-r--r--tests/front-end/raw-string-literal.slang4
-rw-r--r--tests/front-end/subdir/import-subdir-a.slang2
-rw-r--r--tests/ir/string-literal-module.slang2
-rw-r--r--tests/language-feature/extensions/extension-import-helper.slang10
-rw-r--r--tests/language-feature/generics/struct-generic-value-param-import.slang8
-rw-r--r--tests/language-feature/inheritance/struct-inheritance-imported.slang8
-rw-r--r--tests/library/library.slang4
-rw-r--r--tests/reflection/multi-file-defines.h3
-rw-r--r--tests/reflection/multi-file-shared.slang28
-rw-r--r--tests/reflection/reflect-imported-code.slang12
-rw-r--r--tests/vkray/callable-shared.slang6
-rw-r--r--tools/gfx-unit-test/shader-cache-tests.cpp4
-rw-r--r--tools/gfx/gfx.slang1264
-rw-r--r--tools/gfx/slang.slang126
-rw-r--r--tools/slang-unit-test/unit-test-com-host-callable.slang16
-rw-r--r--tools/slang-unit-test/unit-test-translation-unit-import.cpp4
104 files changed, 2180 insertions, 1400 deletions
diff --git a/docs/user-guide/04-modules-and-access-control.md b/docs/user-guide/04-modules-and-access-control.md
new file mode 100644
index 000000000..5beb2b197
--- /dev/null
+++ b/docs/user-guide/04-modules-and-access-control.md
@@ -0,0 +1,169 @@
+
+---
+layout: user-guide
+---
+
+Modules and Access Control
+===========================
+
+While the preprocessor `#include`s is still supported, Slang provides a _module_ system for software engineering benefits such as clean expression of sub-component boundaries and dependencies, hiding implementation details, and providing a path towards true separate compilation.
+
+
+### Defining a Module
+
+A module in Slang comprises one or more files. A module must have one and only one primary file that is used as the source-of-truth to uniquely identify the module. The primary file must start with `module` declaration. For example, the following code defines a module named `scene`:
+
+```
+// scene.slang
+
+module scene;
+
+// ...
+```
+
+A module can contain more than one file. The additional files are pulled into the module with the `__include` syntax:
+
+```
+// scene.slang
+
+module scene;
+
+__include "scene-helpers";
+
+```
+```
+// scene-helpers.slang
+
+implementing scene;
+// ...
+```
+
+The files being included into a module must start with `implementing <module-name>` declaration.
+
+Note that the `__include` syntax here has a different meaning than the preprocessor `#include`. `__include` has the following semantics:
+1. The preprocessor state at which a file inclusion does not apply to the file being included, and the preprocessor state after parsing the included file will not be visible to the outer "includer" file. For example, `#define`s before a `__include` is not visible to the included file, and `#define`s in the included file is not visible to the file that includes it.
+2. A file will be included into the current module exactly once, no matter how many times a `__include` of that file is encountered.
+3. Circular `__include`s are allowed, given (2).
+4. All files that become part of a module via `__include` can access all other entities defined in the same module, regardless the order of `__include`s.
+
+This means that the following code is valid:
+
+```
+// a.slang
+implementing m;
+void f_a() {}
+
+// b.slang
+implementing "m"; // alternate syntax.
+__include a; // pulls in `a` to module `m`.
+void f_b() { f_a(); }
+
+// c.slang
+implementing "m.slang"; // alternate syntax.
+// OK to use f_a and f_b because they are part of module `m`, even
+// if we are not including `a` and `b` here.
+void f_c() { f_a(); f_b(); }
+
+// m.slang
+module m;
+__include m; // OK, a file including itself is allowed and has no effect.
+__include "b"; // Pulls in file b (alternate syntax), and transitively pulls in file a.
+__include "c.slang"; // Pulls in file c, specifying the full file name.
+void test() { f_a(); f_b(); f_c(); }
+```
+
+Note that both `module`, `implementing` and `__include` support two flavors of syntax to refer to a module or a file: either via
+normal identifier tokens or via string literals. For example, the following flavors are equivalent and will resolve to the same file:
+```
+__include dir.file_name; // `file_name` is translated to "file-name".
+__include "dir/file-name.slang";
+__include "dir/file-name";
+```
+
+> #### Note ####
+> When using the identifier token syntax, Slang will translate any underscores(`_`) to hyphenators("-") to obtain the file name.
+
+### Importing a Module
+
+At the global scope of a Slang file, you can use the `import` keyword to import another module by name:
+
+```hlsl
+// MyShader.slang
+
+import YourLibrary;
+```
+
+This `import` declaration will cause the compiler to look for a module named `YourLibrary` and make its declarations visible in the current scope. Similar to `__include`, `import` also supports both the identifier-token and the file-name string syntax.
+
+You can only `import` a primary source file of a module. For example, given:
+```
+// m.slang
+module m;
+__include helper;
+
+// helper.slang
+implementing m;
+// ...
+```
+It is only valid for the user code to `import m`. Attempting to `import helper` will result a compile-time error.
+
+Multiple `import`s of the same module from different input files will only cause the module to be loaded once (there is no need for "include guards" or `#pragma once`).
+Note that preprocessor definitions in the current file will not affect the compilation of `import`ed code, and the preprocessor definitions in the imported code is not visible to the current file.
+
+> #### Note ####
+> Future versions of the Slang system will support loading of modules from pre-compiled binaries instead of source code.
+> The same `import` keyword will continue to work in that case.
+
+### Access Control
+
+Slang supports access control modifiers: `public`, `internal` and `private`. The module boundary plays an important role in access control.
+
+`public` symbols are accessible everywhere: from within the different types, different files or different modules.
+
+`private` symbols are only visible to other symbols in the same type. The following example shows the scope of `private` visibility:
+```csharp
+struct MyType
+{
+ private int member;
+
+ int f() { member = 5; } // OK.
+
+ struct ChildType
+ {
+ int g(MyType t)
+ {
+ return t.member; // OK.
+ }
+ }
+}
+
+void outerFunc(MyType t)
+{
+ t.member = 2; // Error, `member` is not visible here.
+}
+```
+
+`internal` symbols are visible throughout the same module, regardless if it is referenced from the same type or same file. But they are not visible to other modules. The following example shows the scope of `internal` visibility:
+
+```csharp
+// a.slang
+module a;
+__include b;
+internal void f() { f_b(); } // OK, f_b defined in the same module.
+
+// b.slang
+implementing a;
+internal void f_b(); // Defines f_b in module a so they can within the module.
+public void publicFunc();
+
+// m.slang
+module m;
+import a;
+void main()
+{
+ f(); // Error, f is not visible here.
+ publicFunc(); // OK.
+}
+```
+
+`internal` is the default visibility if no other access modifiers are specified.
diff --git a/docs/user-guide/04-interfaces-generics.md b/docs/user-guide/05-interfaces-generics.md
index 94a08714e..94a08714e 100644
--- a/docs/user-guide/04-interfaces-generics.md
+++ b/docs/user-guide/05-interfaces-generics.md
diff --git a/docs/user-guide/05-compiling.md b/docs/user-guide/06-compiling.md
index 5c19175d6..5c19175d6 100644
--- a/docs/user-guide/05-compiling.md
+++ b/docs/user-guide/06-compiling.md
diff --git a/docs/user-guide/06-targets.md b/docs/user-guide/07-targets.md
index d8d71c9e7..d8d71c9e7 100644
--- a/docs/user-guide/06-targets.md
+++ b/docs/user-guide/07-targets.md
diff --git a/docs/user-guide/07-autodiff.md b/docs/user-guide/08-autodiff.md
index a2a06b64b..a2a06b64b 100644
--- a/docs/user-guide/07-autodiff.md
+++ b/docs/user-guide/08-autodiff.md
diff --git a/docs/user-guide/toc.html b/docs/user-guide/toc.html
index 48a7780d6..615b96b15 100644
--- a/docs/user-guide/toc.html
+++ b/docs/user-guide/toc.html
@@ -45,51 +45,53 @@
<li data-link="03-convenience-features#modules"><span>Modules</span></li>
</ul>
</li>
-<li data-link="04-interfaces-generics"><span>Interfaces and Generics</span>
+<li data-link="04-modules-and-access-control"><span>Modules and Access Control</span>
+</li>
+<li data-link="05-interfaces-generics"><span>Interfaces and Generics</span>
<ul class="toc_list">
-<li data-link="04-interfaces-generics#interfaces"><span>Interfaces</span></li>
-<li data-link="04-interfaces-generics#generics"><span>Generics</span></li>
-<li data-link="04-interfaces-generics#supported-constructs-in-interface-definitions"><span>Supported Constructs in Interface Definitions</span></li>
-<li data-link="04-interfaces-generics#associated-types"><span>Associated Types</span></li>
-<li data-link="04-interfaces-generics#generic-value-parameters"><span>Generic Value Parameters</span></li>
-<li data-link="04-interfaces-generics#interface-typed-values"><span>Interface-typed Values</span></li>
-<li data-link="04-interfaces-generics#extending-a-type-with-additional-interface-conformances"><span>Extending a Type with Additional Interface Conformances</span></li>
-<li data-link="04-interfaces-generics#is-and-as-operator"><span>`is` and `as` Operator</span></li>
-<li data-link="04-interfaces-generics#extensions-to-interfaces"><span>Extensions to Interfaces</span></li>
+<li data-link="05-interfaces-generics#interfaces"><span>Interfaces</span></li>
+<li data-link="05-interfaces-generics#generics"><span>Generics</span></li>
+<li data-link="05-interfaces-generics#supported-constructs-in-interface-definitions"><span>Supported Constructs in Interface Definitions</span></li>
+<li data-link="05-interfaces-generics#associated-types"><span>Associated Types</span></li>
+<li data-link="05-interfaces-generics#generic-value-parameters"><span>Generic Value Parameters</span></li>
+<li data-link="05-interfaces-generics#interface-typed-values"><span>Interface-typed Values</span></li>
+<li data-link="05-interfaces-generics#extending-a-type-with-additional-interface-conformances"><span>Extending a Type with Additional Interface Conformances</span></li>
+<li data-link="05-interfaces-generics#is-and-as-operator"><span>`is` and `as` Operator</span></li>
+<li data-link="05-interfaces-generics#extensions-to-interfaces"><span>Extensions to Interfaces</span></li>
</ul>
</li>
-<li data-link="05-compiling"><span>Compiling Code with Slang</span>
+<li data-link="06-compiling"><span>Compiling Code with Slang</span>
<ul class="toc_list">
-<li data-link="05-compiling#concepts"><span>Concepts</span></li>
-<li data-link="05-compiling#command-line-compilation-with-slangc"><span>Command-Line Compilation with `slangc`</span></li>
-<li data-link="05-compiling#using-the-compilation-api"><span>Using the Compilation API</span></li>
+<li data-link="06-compiling#concepts"><span>Concepts</span></li>
+<li data-link="06-compiling#command-line-compilation-with-slangc"><span>Command-Line Compilation with `slangc`</span></li>
+<li data-link="06-compiling#using-the-compilation-api"><span>Using the Compilation API</span></li>
</ul>
</li>
-<li data-link="06-targets"><span>Supported Compilation Targets</span>
+<li data-link="07-targets"><span>Supported Compilation Targets</span>
<ul class="toc_list">
-<li data-link="06-targets#background-and-terminology"><span>Background and Terminology</span></li>
-<li data-link="06-targets#direct3d-11"><span>Direct3D 11</span></li>
-<li data-link="06-targets#direct3d-12"><span>Direct3D 12</span></li>
-<li data-link="06-targets#vulkan"><span>Vulkan</span></li>
-<li data-link="06-targets#opengl"><span>OpenGL</span></li>
-<li data-link="06-targets#cuda-and-optix"><span>CUDA and OptiX</span></li>
-<li data-link="06-targets#cpu-compute"><span>CPU Compute</span></li>
-<li data-link="06-targets#summary"><span>Summary</span></li>
+<li data-link="07-targets#background-and-terminology"><span>Background and Terminology</span></li>
+<li data-link="07-targets#direct3d-11"><span>Direct3D 11</span></li>
+<li data-link="07-targets#direct3d-12"><span>Direct3D 12</span></li>
+<li data-link="07-targets#vulkan"><span>Vulkan</span></li>
+<li data-link="07-targets#opengl"><span>OpenGL</span></li>
+<li data-link="07-targets#cuda-and-optix"><span>CUDA and OptiX</span></li>
+<li data-link="07-targets#cpu-compute"><span>CPU Compute</span></li>
+<li data-link="07-targets#summary"><span>Summary</span></li>
</ul>
</li>
-<li data-link="07-autodiff"><span>Automatic Differentiation</span>
+<li data-link="08-autodiff"><span>Automatic Differentiation</span>
<ul class="toc_list">
-<li data-link="07-autodiff#using-automatic-differentiation-in-slang"><span>Using Automatic Differentiation in Slang</span></li>
-<li data-link="07-autodiff#mathematic-concepts-and-terminologies"><span>Mathematic Concepts and Terminologies</span></li>
-<li data-link="07-autodiff#differentiable-types"><span>Differentiable Types</span></li>
-<li data-link="07-autodiff#forward-derivative-propagation-function"><span>Forward Derivative Propagation Function</span></li>
-<li data-link="07-autodiff#backward-derivative-propagation-function"><span>Backward Derivative Propagation Function</span></li>
-<li data-link="07-autodiff#builtin-differentiable-functions"><span>Builtin Differentiable Functions</span></li>
-<li data-link="07-autodiff#primal-substitute-functions"><span>Primal Substitute Functions</span></li>
-<li data-link="07-autodiff#working-with-mixed-differentiable-and-non-differentiable-code"><span>Working with Mixed Differentiable and Non-Differentiable Code</span></li>
-<li data-link="07-autodiff#higher-order-differentiation"><span>Higher Order Differentiation</span></li>
-<li data-link="07-autodiff#interactions-with-generics-and-interfaces"><span>Interactions with Generics and Interfaces</span></li>
-<li data-link="07-autodiff#restrictions-of-automatic-differentiation"><span>Restrictions of Automatic Differentiation</span></li>
+<li data-link="08-autodiff#using-automatic-differentiation-in-slang"><span>Using Automatic Differentiation in Slang</span></li>
+<li data-link="08-autodiff#mathematic-concepts-and-terminologies"><span>Mathematic Concepts and Terminologies</span></li>
+<li data-link="08-autodiff#differentiable-types"><span>Differentiable Types</span></li>
+<li data-link="08-autodiff#forward-derivative-propagation-function"><span>Forward Derivative Propagation Function</span></li>
+<li data-link="08-autodiff#backward-derivative-propagation-function"><span>Backward Derivative Propagation Function</span></li>
+<li data-link="08-autodiff#builtin-differentiable-functions"><span>Builtin Differentiable Functions</span></li>
+<li data-link="08-autodiff#primal-substitute-functions"><span>Primal Substitute Functions</span></li>
+<li data-link="08-autodiff#working-with-mixed-differentiable-and-non-differentiable-code"><span>Working with Mixed Differentiable and Non-Differentiable Code</span></li>
+<li data-link="08-autodiff#higher-order-differentiation"><span>Higher Order Differentiation</span></li>
+<li data-link="08-autodiff#interactions-with-generics-and-interfaces"><span>Interactions with Generics and Interfaces</span></li>
+<li data-link="08-autodiff#restrictions-of-automatic-differentiation"><span>Restrictions of Automatic Differentiation</span></li>
</ul>
</li>
<li data-link="a1-special-topics"><span>Special Topics</span>
diff --git a/examples/cpu-com-example/shader.slang b/examples/cpu-com-example/shader.slang
index 951fdc218..b312da364 100644
--- a/examples/cpu-com-example/shader.slang
+++ b/examples/cpu-com-example/shader.slang
@@ -2,9 +2,9 @@
// Example using 'NativeString' and COM interface
-public __global __extern_cpp IDoThings globalDoThings;
+export __global __extern_cpp IDoThings globalDoThings;
-public __extern_cpp NativeString getString(NativeString in)
+export __extern_cpp NativeString getString(NativeString in)
{
return in;
}
@@ -17,12 +17,12 @@ interface IDoThings
void printMessage(NativeString nativeString);
}
-public __extern_cpp int calcHash(NativeString text)
+export __extern_cpp int calcHash(NativeString text)
{
return globalDoThings.calcHash(text);
}
-public __extern_cpp void printMessage(NativeString text)
+export __extern_cpp void printMessage(NativeString text)
{
return globalDoThings.printMessage(text);
}
diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang
index 31ed5845e..6f4888a5d 100644
--- a/source/slang/diff.meta.slang
+++ b/source/slang/diff.meta.slang
@@ -26,7 +26,7 @@ __attributeTarget(FunctionDeclBase)
attribute_syntax [NoDiffThis] : NoDiffThisAttribute;
// A 'none-type' that acts as a run-time sentinel for zero differentials.
-public struct NullDifferential : IDifferentiable
+export struct NullDifferential : IDifferentiable
{
// for now, we'll use at least one field to make sure the type is non-empty
uint dummy;
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang
index 98f30cd3c..a43a7ba3c 100644
--- a/source/slang/glsl.meta.slang
+++ b/source/slang/glsl.meta.slang
@@ -2,385 +2,385 @@
// From the GLSL spec, section 4.1. 'asic Types'
//
-typealias vec2 = vector<float, 2>;
-typealias vec3 = vector<float, 3>;
-typealias vec4 = vector<float, 4>;
-
-typealias dvec2 = vector<double, 2>;
-typealias dvec3 = vector<double, 3>;
-typealias dvec4 = vector<double, 4>;
-
-typealias bvec2 = vector<bool, 2>;
-typealias bvec3 = vector<bool, 3>;
-typealias bvec4 = vector<bool, 4>;
-
-typealias ivec2 = vector<int, 2>;
-typealias ivec3 = vector<int, 3>;
-typealias ivec4 = vector<int, 4>;
-
-typealias uvec2 = vector<uint, 2>;
-typealias uvec3 = vector<uint, 3>;
-typealias uvec4 = vector<uint, 4>;
-
-typealias i8vec2 = vector<int8_t, 2>;
-typealias i8vec3 = vector<int8_t, 3>;
-typealias i8vec4 = vector<int8_t, 4>;
-
-typealias u8vec2 = vector<uint8_t, 2>;
-typealias u8vec3 = vector<uint8_t, 3>;
-typealias u8vec4 = vector<uint8_t, 4>;
-
-typealias i16vec2 = vector<int16_t, 2>;
-typealias i16vec3 = vector<int16_t, 3>;
-typealias i16vec4 = vector<int16_t, 4>;
-
-typealias u16vec2 = vector<uint16_t, 2>;
-typealias u16vec3 = vector<uint16_t, 3>;
-typealias u16vec4 = vector<uint16_t, 4>;
-
-typealias i64vec2 = vector<int64_t, 2>;
-typealias i64vec3 = vector<int64_t, 3>;
-typealias i64vec4 = vector<int64_t, 4>;
-
-typealias u64vec2 = vector<uint64_t, 2>;
-typealias u64vec3 = vector<uint64_t, 3>;
-typealias u64vec4 = vector<uint64_t, 4>;
-
-typealias mat2 = matrix<float, 2, 2>;
-typealias mat3 = matrix<float, 3, 3>;
-typealias mat4 = matrix<float, 4, 4>;
-
-typealias mat2x2 = matrix<float, 2, 2>;
-typealias mat2x3 = matrix<float, 3, 2>;
-typealias mat2x4 = matrix<float, 4, 2>;
-
-typealias mat3x2 = matrix<float, 2, 3>;
-typealias mat3x3 = matrix<float, 3, 3>;
-typealias mat3x4 = matrix<float, 4, 3>;
-
-typealias mat4x2 = matrix<float, 2, 4>;
-typealias mat4x3 = matrix<float, 3, 4>;
-typealias mat4x4 = matrix<float, 4, 4>;
-
-typealias dmat2 = matrix<double, 2, 2>;
-typealias dmat3 = matrix<double, 3, 3>;
-typealias dmat4 = matrix<double, 4, 4>;
-
-typealias dmat2x2 = matrix<double, 2, 2>;
-typealias dmat2x3 = matrix<double, 3, 2>;
-typealias dmat2x4 = matrix<double, 4, 2>;
-
-typealias dmat3x2 = matrix<double, 2, 3>;
-typealias dmat3x3 = matrix<double, 3, 3>;
-typealias dmat3x4 = matrix<double, 4, 3>;
-
-typealias dmat4x2 = matrix<double, 2, 4>;
-typealias dmat4x3 = matrix<double, 3, 4>;
-typealias dmat4x4 = matrix<double, 4, 4>;
-
-typealias usampler1D = Sampler1D<uint4>;
-typealias isampler1D = Sampler1D<int4>;
-typealias sampler1D = Sampler1D<float4>;
-
-typealias usampler2D = Sampler2D<uint4>;
-typealias isampler2D = Sampler2D<int4>;
-typealias sampler2D = Sampler2D<float4>;
-
-typealias usampler3D = Sampler3D<uint4>;
-typealias isampler3D = Sampler3D<int4>;
-typealias sampler3D = Sampler3D<float4>;
-
-typealias usamplerCube = SamplerCube<uint4>;
-typealias isamplerCube = SamplerCube<int4>;
-typealias samplerCube = SamplerCube<float4>;
-
-typealias Sampler1DShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usampler1DShadow = Sampler1DShadow<uint>;
-typealias isampler1DShadow = Sampler1DShadow<int>;
-typealias sampler1DShadow = Sampler1DShadow<float>;
-
-typealias Sampler2DShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usampler2DShadow = Sampler2DShadow<uint>;
-typealias isampler2DShadow = Sampler2DShadow<int>;
-typealias sampler2DShadow = Sampler2DShadow<float>;
-
-typealias SamplerCubeShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usamplerCubeShadow = SamplerCubeShadow<uint>;
-typealias isamplerCubeShadow = SamplerCubeShadow<int>;
-typealias samplerCubeShadow = SamplerCubeShadow<float>;
-
-typealias usampler1DArray = Sampler1DArray<uint4>;
-typealias isampler1DArray = Sampler1DArray<int4>;
-typealias sampler1DArray = Sampler1DArray<float4>;
-
-typealias usampler2DArray = Sampler2DArray<uint4>;
-typealias isampler2DArray = Sampler2DArray<int4>;
-typealias sampler2DArray = Sampler2DArray<float4>;
-
-typealias usamplerCubeArray = SamplerCubeArray<uint4>;
-typealias isamplerCubeArray = SamplerCubeArray<int4>;
-typealias samplerCubeArray = SamplerCubeArray<float4>;
-
-typealias Sampler1DArrayShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usampler1DArrayShadow = Sampler1DArrayShadow<uint>;
-typealias isampler1DArrayShadow = Sampler1DArrayShadow<int>;
-typealias sampler1DArrayShadow = Sampler1DArrayShadow<float>;
+public typealias vec2 = vector<float, 2>;
+public typealias vec3 = vector<float, 3>;
+public typealias vec4 = vector<float, 4>;
+
+public typealias dvec2 = vector<double, 2>;
+public typealias dvec3 = vector<double, 3>;
+public typealias dvec4 = vector<double, 4>;
+
+public typealias bvec2 = vector<bool, 2>;
+public typealias bvec3 = vector<bool, 3>;
+public typealias bvec4 = vector<bool, 4>;
+
+public typealias ivec2 = vector<int, 2>;
+public typealias ivec3 = vector<int, 3>;
+public typealias ivec4 = vector<int, 4>;
+
+public typealias uvec2 = vector<uint, 2>;
+public typealias uvec3 = vector<uint, 3>;
+public typealias uvec4 = vector<uint, 4>;
+
+public typealias i8vec2 = vector<int8_t, 2>;
+public typealias i8vec3 = vector<int8_t, 3>;
+public typealias i8vec4 = vector<int8_t, 4>;
+
+public typealias u8vec2 = vector<uint8_t, 2>;
+public typealias u8vec3 = vector<uint8_t, 3>;
+public typealias u8vec4 = vector<uint8_t, 4>;
+
+public typealias i16vec2 = vector<int16_t, 2>;
+public typealias i16vec3 = vector<int16_t, 3>;
+public typealias i16vec4 = vector<int16_t, 4>;
+
+public typealias u16vec2 = vector<uint16_t, 2>;
+public typealias u16vec3 = vector<uint16_t, 3>;
+public typealias u16vec4 = vector<uint16_t, 4>;
+
+public typealias i64vec2 = vector<int64_t, 2>;
+public typealias i64vec3 = vector<int64_t, 3>;
+public typealias i64vec4 = vector<int64_t, 4>;
+
+public typealias u64vec2 = vector<uint64_t, 2>;
+public typealias u64vec3 = vector<uint64_t, 3>;
+public typealias u64vec4 = vector<uint64_t, 4>;
+
+public typealias mat2 = matrix<float, 2, 2>;
+public typealias mat3 = matrix<float, 3, 3>;
+public typealias mat4 = matrix<float, 4, 4>;
+
+public typealias mat2x2 = matrix<float, 2, 2>;
+public typealias mat2x3 = matrix<float, 3, 2>;
+public typealias mat2x4 = matrix<float, 4, 2>;
+
+public typealias mat3x2 = matrix<float, 2, 3>;
+public typealias mat3x3 = matrix<float, 3, 3>;
+public typealias mat3x4 = matrix<float, 4, 3>;
+
+public typealias mat4x2 = matrix<float, 2, 4>;
+public typealias mat4x3 = matrix<float, 3, 4>;
+public typealias mat4x4 = matrix<float, 4, 4>;
+
+public typealias dmat2 = matrix<double, 2, 2>;
+public typealias dmat3 = matrix<double, 3, 3>;
+public typealias dmat4 = matrix<double, 4, 4>;
+
+public typealias dmat2x2 = matrix<double, 2, 2>;
+public typealias dmat2x3 = matrix<double, 3, 2>;
+public typealias dmat2x4 = matrix<double, 4, 2>;
+
+public typealias dmat3x2 = matrix<double, 2, 3>;
+public typealias dmat3x3 = matrix<double, 3, 3>;
+public typealias dmat3x4 = matrix<double, 4, 3>;
+
+public typealias dmat4x2 = matrix<double, 2, 4>;
+public typealias dmat4x3 = matrix<double, 3, 4>;
+public typealias dmat4x4 = matrix<double, 4, 4>;
+
+public typealias usampler1D = Sampler1D<uint4>;
+public typealias isampler1D = Sampler1D<int4>;
+public typealias sampler1D = Sampler1D<float4>;
+
+public typealias usampler2D = Sampler2D<uint4>;
+public typealias isampler2D = Sampler2D<int4>;
+public typealias sampler2D = Sampler2D<float4>;
+
+public typealias usampler3D = Sampler3D<uint4>;
+public typealias isampler3D = Sampler3D<int4>;
+public typealias sampler3D = Sampler3D<float4>;
+
+public typealias usamplerCube = SamplerCube<uint4>;
+public typealias isamplerCube = SamplerCube<int4>;
+public typealias samplerCube = SamplerCube<float4>;
+
+public typealias Sampler1DShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usampler1DShadow = Sampler1DShadow<uint>;
+public typealias isampler1DShadow = Sampler1DShadow<int>;
+public typealias sampler1DShadow = Sampler1DShadow<float>;
+
+public typealias Sampler2DShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usampler2DShadow = Sampler2DShadow<uint>;
+public typealias isampler2DShadow = Sampler2DShadow<int>;
+public typealias sampler2DShadow = Sampler2DShadow<float>;
+
+public typealias SamplerCubeShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usamplerCubeShadow = SamplerCubeShadow<uint>;
+public typealias isamplerCubeShadow = SamplerCubeShadow<int>;
+public typealias samplerCubeShadow = SamplerCubeShadow<float>;
+
+public typealias usampler1DArray = Sampler1DArray<uint4>;
+public typealias isampler1DArray = Sampler1DArray<int4>;
+public typealias sampler1DArray = Sampler1DArray<float4>;
+
+public typealias usampler2DArray = Sampler2DArray<uint4>;
+public typealias isampler2DArray = Sampler2DArray<int4>;
+public typealias sampler2DArray = Sampler2DArray<float4>;
+
+public typealias usamplerCubeArray = SamplerCubeArray<uint4>;
+public typealias isamplerCubeArray = SamplerCubeArray<int4>;
+public typealias samplerCubeArray = SamplerCubeArray<float4>;
+
+public typealias Sampler1DArrayShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usampler1DArrayShadow = Sampler1DArrayShadow<uint>;
+public typealias isampler1DArrayShadow = Sampler1DArrayShadow<int>;
+public typealias sampler1DArrayShadow = Sampler1DArrayShadow<float>;
-typealias Sampler2DArrayShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usampler2DArrayShadow = Sampler2DArrayShadow<uint>;
-typealias isampler2DArrayShadow = Sampler2DArrayShadow<int>;
-typealias sampler2DArrayShadow = Sampler2DArrayShadow<float>;
-
-typealias SamplerCubeArrayShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-typealias usamplerCubeArrayShadow = SamplerCubeArrayShadow<uint>;
-typealias isamplerCubeArrayShadow = SamplerCubeArrayShadow<int>;
-typealias samplerCubeArrayShadow = SamplerCubeArrayShadow<float>;
+public typealias Sampler2DArrayShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usampler2DArrayShadow = Sampler2DArrayShadow<uint>;
+public typealias isampler2DArrayShadow = Sampler2DArrayShadow<int>;
+public typealias sampler2DArrayShadow = Sampler2DArrayShadow<float>;
+
+public typealias SamplerCubeArrayShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
+public typealias usamplerCubeArrayShadow = SamplerCubeArrayShadow<uint>;
+public typealias isamplerCubeArrayShadow = SamplerCubeArrayShadow<int>;
+public typealias samplerCubeArrayShadow = SamplerCubeArrayShadow<float>;
[ForceInline]
-vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1D<vector<T,N>> sampler, int p, int lod)
+public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1D<vector<T,N>> sampler, int p, int lod)
{
return __vectorReshape<4>(sampler.Load(int2(p, lod)));
}
[ForceInline]
-vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2D<vector<T,N>> sampler, ivec2 p, int lod)
+public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2D<vector<T,N>> sampler, ivec2 p, int lod)
{
return __vectorReshape<4>(sampler.Load(int3(p, lod)));
}
[ForceInline]
-vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler3D<vector<T,N>> sampler, ivec3 p, int lod)
+public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler3D<vector<T,N>> sampler, ivec3 p, int lod)
{
return __vectorReshape<4>(sampler.Load(int4(p, lod)));
}
[ForceInline]
-vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1DArray<vector<T,N>> sampler, ivec2 p, int lod)
+public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1DArray<vector<T,N>> sampler, ivec2 p, int lod)
{
return __vectorReshape<4>(sampler.Load(int3(p, lod)));
}
[ForceInline]
-vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2DArray<vector<T,N>> sampler, ivec3 p, int lod)
+public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2DArray<vector<T,N>> sampler, ivec3 p, int lod)
{
return __vectorReshape<4>(sampler.Load(int4(p, lod)));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler1D<vector<T,N>> sampler, float p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler1D<vector<T,N>> sampler, float p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler2D<vector<T,N>> sampler, float2 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler2D<vector<T,N>> sampler, float2 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler3D<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler3D<vector<T,N>> sampler, float3 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (SamplerCube<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (SamplerCube<vector<T,N>> sampler, float3 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-float texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DShadow<vector<T,N>> sampler, float2 p)
+public float texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DShadow<vector<T,N>> sampler, float2 p)
{
return sampler.SampleCmp(p.x, p.y);
}
[ForceInline]
-float texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DShadow<vector<T,N>> sampler, float3 p)
+public float texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DShadow<vector<T,N>> sampler, float3 p)
{
return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-float texture<T:__BuiltinArithmeticType, let N : int> (SamplerCubeShadow<vector<T,N>> sampler, float4 p)
+public float texture<T:__BuiltinArithmeticType, let N : int> (SamplerCubeShadow<vector<T,N>> sampler, float4 p)
{
return sampler.SampleCmp(p.xyz, p.w);
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DArray<vector<T,N>> sampler, float2 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DArray<vector<T,N>> sampler, float2 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DArray<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DArray<vector<T,N>> sampler, float3 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (SamplerCubeArray<vector<T,N>> sampler, float4 p, float bias = 0.0)
+public vector<T,4> texture<T:__BuiltinArithmeticType, let N : int> (SamplerCubeArray<vector<T,N>> sampler, float4 p, float bias = 0.0)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-float texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DArrayShadow<vector<T,N>> sampler, float3 p)
+public float texture<T:__BuiltinArithmeticType, let N : int> (Sampler1DArrayShadow<vector<T,N>> sampler, float3 p)
{
return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-float texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DArrayShadow<vector<T,N>> sampler, float4 p)
+public float texture<T:__BuiltinArithmeticType, let N : int> (Sampler2DArrayShadow<vector<T,N>> sampler, float4 p)
{
return sampler.SampleCmp(p.xyz, p.w);
}
__generic<T:__BuiltinArithmeticType, let N : int, shape:__ITextureShape, let sampleCount: int, let isArray:int, let format:int>
-vector<T,4> textureGrad(__TextureImpl<vector<T,N>, shape, isArray, 0, sampleCount, 0, 1, 1, format> sampler, vector<float, shape.dimensions+isArray> P, vector<float,shape.planeDimensions> dPdx, vector<float,shape.planeDimensions> dPdy)
+public vector<T,4> textureGrad(__TextureImpl<vector<T,N>, shape, isArray, 0, sampleCount, 0, 1, 1, format> sampler, vector<float, shape.dimensions+isArray> P, vector<float,shape.planeDimensions> dPdx, vector<float,shape.planeDimensions> dPdy)
{
return __vectorReshape<4>(sampler.SampleGrad(P, dPdx, dPdy));
}
-out float4 gl_Position : SV_Position;
-out float gl_PointSize : SV_PointSize;
-in vec4 gl_FragCoord : SV_Position;
-out float gl_FragDepth : SV_Depth;
-out int gl_FragStencilRef : SV_StencilRef;
+public out float4 gl_Position : SV_Position;
+public out float gl_PointSize : SV_PointSize;
+public in vec4 gl_FragCoord : SV_Position;
+public out float gl_FragDepth : SV_Depth;
+public out int gl_FragStencilRef : SV_StencilRef;
-in uvec3 gl_GlobalInvocationID : SV_DispatchThreadID;
-in uvec3 gl_WorkGroupID : SV_GroupID;
-in uvec3 gl_LocalInvocationIndex : SV_GroupIndex;
-in uvec3 gl_LocalInvocationID : SV_GroupThreadID;
+public in uvec3 gl_GlobalInvocationID : SV_DispatchThreadID;
+public in uvec3 gl_WorkGroupID : SV_GroupID;
+public in uvec3 gl_LocalInvocationIndex : SV_GroupIndex;
+public in uvec3 gl_LocalInvocationID : SV_GroupThreadID;
// TODO: define overload for tessellation control stage.
-in int gl_InvocationID : SV_GSInstanceID;
+public in int gl_InvocationID : SV_GSInstanceID;
-in int gl_InstanceIndex : SV_InstanceID;
-in bool gl_FrontFacing : SV_IsFrontFace;
+public in int gl_InstanceIndex : SV_InstanceID;
+public in bool gl_FrontFacing : SV_IsFrontFace;
// TODO: define overload for geometry stage.
-in int gl_Layer : SV_RenderTargetArrayIndex;
+public in int gl_Layer : SV_RenderTargetArrayIndex;
-in int gl_SampleID : SV_SampleIndex;
-in int gl_VertexIndex : SV_VertexID;
-in int gl_ViewIndex : SV_ViewID;
-in int gl_ViewportIndex : SV_ViewportArrayIndex;
+public in int gl_SampleID : SV_SampleIndex;
+public in int gl_VertexIndex : SV_VertexID;
+public in int gl_ViewIndex : SV_ViewID;
+public in int gl_ViewportIndex : SV_ViewportArrayIndex;
// Override operator* behavior to compute algebric product of matrices and vectors.
[OverloadRank(15)]
[ForceInline]
-matrix<float, N, N> operator*<let N : int>(matrix<float, N, N> m1, matrix<float, N, N> m2)
+public matrix<float, N, N> operator*<let N : int>(matrix<float, N, N> m1, matrix<float, N, N> m2)
{
return mul(m2, m1);
}
[OverloadRank(15)]
[ForceInline]
-matrix<half, N, N> operator*<let N : int>(matrix<half, N, N> m1, matrix<half, N, N> m2)
+public matrix<half, N, N> operator*<let N : int>(matrix<half, N, N> m1, matrix<half, N, N> m2)
{
return mul(m2, m1);
}
[OverloadRank(15)]
[ForceInline]
-matrix<double, N, N> operator*<let N : int>(matrix<double, N, N> m1, matrix<double, N, N> m2)
+public matrix<double, N, N> operator*<let N : int>(matrix<double, N, N> m1, matrix<double, N, N> m2)
{
return mul(m2, m1);
}
[ForceInline]
[OverloadRank(15)]
-matrix<T, R, L> operator*<T:__BuiltinFloatingPointType, let L : int, let C : int, let R : int>(matrix<T, C, L> m1, matrix<T, R, C> m2)
+public matrix<T, R, L> operator*<T:__BuiltinFloatingPointType, let L : int, let C : int, let R : int>(matrix<T, C, L> m1, matrix<T, R, C> m2)
{
return mul(m2, m1);
}
[ForceInline]
[OverloadRank(15)]
-vector<T, R> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(vector<T, C> v, matrix<T, R, C> m)
+public vector<T, R> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(vector<T, C> v, matrix<T, R, C> m)
{
return mul(m, v);
}
[ForceInline]
[OverloadRank(15)]
-vector<T, C> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(matrix<T, R, C> m, vector<T, R> v)
+public vector<T, C> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(matrix<T, R, C> m, vector<T, R> v)
{
return mul(v, m);
}
__intrinsic_op(mul)
-matrix<T, N, M> matrixCompMult<T:__BuiltinFloatingPointType, let N : int, let M : int>(matrix<T,N,M> left, matrix<T,N,M> right);
+public matrix<T, N, M> matrixCompMult<T:__BuiltinFloatingPointType, let N : int, let M : int>(matrix<T,N,M> left, matrix<T,N,M> right);
__intrinsic_op(cmpLE)
-vector<bool, N> lessThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> lessThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
__intrinsic_op(cmpLT)
-vector<bool, N> lessThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> lessThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
__intrinsic_op(cmpGT)
-vector<bool, N> greaterThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> greaterThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
__intrinsic_op(cmpGE)
-vector<bool, N> greaterThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> greaterThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
__intrinsic_op(cmpEQ)
-vector<bool, N> equal<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> equal<T, let N:int>(vector<T, N> x, vector<T, N> y);
__intrinsic_op(cmpNE)
-vector<bool, N> notEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+public vector<bool, N> notEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
__generic<T>
-extension vector<T, 2>
+public extension vector<T, 2>
{
- [ForceInline] __init(vector<T, 3> bigger) { this = bigger.xy; }
- [ForceInline] __init(vector<T, 4> bigger) { this = bigger.xy; }
+ [ForceInline] public __init(vector<T, 3> bigger) { this = bigger.xy; }
+ [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xy; }
}
__generic<T>
-extension vector<T, 3>
+public extension vector<T, 3>
{
- [ForceInline] __init(vector<T, 4> bigger) { this = bigger.xyz; }
+ [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xyz; }
}
[ForceInline]
[OverloadRank(15)]
-bool operator==<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator==<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return all(equal(left, right));
}
[ForceInline]
[OverloadRank(15)]
-bool operator!=<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator!=<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return any(notEqual(left, right));
}
[ForceInline]
[OverloadRank(14)]
-bool operator==<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator==<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return all(equal(left, right));
}
[ForceInline]
[OverloadRank(14)]
-bool operator!=<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator!=<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return any(notEqual(left, right));
}
[ForceInline]
[OverloadRank(14)]
-bool operator==<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator==<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return all(equal(left, right));
}
[ForceInline]
[OverloadRank(14)]
-bool operator!=<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+public bool operator!=<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
{
return any(notEqual(left, right));
}
@@ -392,14 +392,14 @@ for (auto type : kBaseTypes) {
}}}}
[ForceInline]
[OverloadRank(15)]
-bool operator==<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+public bool operator==<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
{
return all(equal(left, right));
}
[ForceInline]
[OverloadRank(15)]
-bool operator!=<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+public bool operator!=<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
{
return any(notEqual(left, right));
}
@@ -407,13 +407,13 @@ ${{{{
}
}}}}
-[ForceInline] int findLSB(int v) { return firstbitlow(v); }
-[ForceInline] uint findLSB(uint v) { return firstbitlow(v); }
-[ForceInline] vector<int,N> findLSB<let N:int>(vector<int,N> value)
+[ForceInline] public int findLSB(int v) { return firstbitlow(v); }
+[ForceInline] public uint findLSB(uint v) { return firstbitlow(v); }
+[ForceInline] public vector<int,N> findLSB<let N:int>(vector<int,N> value)
{
return firstbitlow(value);
}
-[ForceInline] vector<uint,N> findLSB<let N:int>(vector<uint,N> value)
+[ForceInline] public vector<uint,N> findLSB<let N:int>(vector<uint,N> value)
{
return firstbitlow(value);
}
diff --git a/source/slang/slang-ast-decl.h b/source/slang/slang-ast-decl.h
index ddff39502..ab4fbaf17 100644
--- a/source/slang/slang-ast-decl.h
+++ b/source/slang/slang-ast-decl.h
@@ -426,6 +426,15 @@ class ModuleDecl : public NamespaceDeclBase
///
OrderedDictionary<Decl*, RefPtr<DeclAssociationList>> mapDeclToAssociatedDecls;
+ /// Whether the module is defined in legacy language.
+ /// The legacy Slang language does not have visibility modifiers and everything is treated as
+ /// `public`. Newer version of the language introduces visibility and makes `internal` as the
+ /// default. To prevent this from breaking existing code, we need to know whether a module is
+ /// written in the legacy language. We detect this by checking whether the module has any
+ /// visibility modifiers, or if the module uses new language constructs, e.g. `module`, `__include`,
+ /// `__implementing` etc.
+ bool isInLegacyLanguage = true;
+
SLANG_UNREFLECTED
/// Map a type to the list of extensions of that type (if any) declared in this module
diff --git a/source/slang/slang-ast-modifier.h b/source/slang/slang-ast-modifier.h
index 9ee3fea86..ae87c4e10 100644
--- a/source/slang/slang-ast-modifier.h
+++ b/source/slang/slang-ast-modifier.h
@@ -16,7 +16,10 @@ class ConstModifier : public Modifier { SLANG_AST_CLASS(ConstModifier)};
class InstanceModifier : public Modifier { SLANG_AST_CLASS(InstanceModifier)};
class BuiltinModifier : public Modifier { SLANG_AST_CLASS(BuiltinModifier)};
class InlineModifier : public Modifier { SLANG_AST_CLASS(InlineModifier)};
-class PublicModifier : public Modifier { SLANG_AST_CLASS(PublicModifier)};
+class VisibilityModifier : public Modifier {SLANG_AST_CLASS(VisibilityModifier)};
+class PublicModifier : public VisibilityModifier { SLANG_AST_CLASS(PublicModifier)};
+class PrivateModifier : public VisibilityModifier { SLANG_AST_CLASS(PrivateModifier) };
+class InternalModifier : public VisibilityModifier { SLANG_AST_CLASS(InternalModifier) };
class RequireModifier : public Modifier { SLANG_AST_CLASS(RequireModifier)};
class ParamModifier : public Modifier { SLANG_AST_CLASS(ParamModifier)};
class ExternModifier : public Modifier { SLANG_AST_CLASS(ExternModifier)};
diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h
index 5da19f377..1e71d0c4a 100644
--- a/source/slang/slang-ast-support-types.h
+++ b/source/slang/slang-ast-support-types.h
@@ -1598,7 +1598,13 @@ namespace Slang
/// Get the operator name from the higher order invoke expr.
UnownedStringSlice getHigherOrderOperatorName(HigherOrderInvokeExpr* expr);
-
+ enum class DeclVisibility
+ {
+ Private,
+ Internal,
+ Public,
+ Default = Internal,
+ };
} // namespace Slang
#endif
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp
index c2cfabcfe..d76b2a80e 100644
--- a/source/slang/slang-check-conversion.cpp
+++ b/source/slang/slang-check-conversion.cpp
@@ -1063,7 +1063,7 @@ namespace Slang
overloadContext.argCount = 1;
overloadContext.argTypes = &fromType.type;
overloadContext.args = &fromExpr;
-
+ overloadContext.sourceScope = m_outerScope;
overloadContext.originalExpr = nullptr;
if(fromExpr)
{
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index b4cc6c00a..671bb26dd 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -298,7 +298,9 @@ namespace Slang
{
// Things at the global scope are always "members" of their module.
//
- if(as<ModuleDecl>(parentDecl))
+ if(as<NamespaceDeclBase>(parentDecl))
+ return false;
+ if (as<FileDecl>(parentDecl))
return false;
// Anything explicitly marked `static` and not at module scope
@@ -373,7 +375,7 @@ namespace Slang
auto parentDecl = decl->parentDecl;
if (auto genericDecl = as<GenericDecl>(parentDecl))
parentDecl = genericDecl->parentDecl;
- return as<NamespaceDeclBase>(parentDecl) != nullptr;
+ return as<NamespaceDeclBase>(parentDecl) != nullptr || as<FileDecl>(parentDecl) != nullptr;
}
/// Is `decl` a global shader parameter declaration?
@@ -385,7 +387,7 @@ namespace Slang
// A global shader parameter must be declared at global or namespace
// scope, so that it has a single definition across the module.
//
- if(!as<NamespaceDeclBase>(decl->parentDecl)) return false;
+ if(!isGlobalDecl(decl)) return false;
// A global variable marked `static` indicates a traditional
// global variable (albeit one that is implicitly local to
@@ -733,6 +735,7 @@ namespace Slang
// The coding of this loop is somewhat defensive to deal
// with special cases that will be described along the way.
//
+ auto outerScope = getScope(decl);
for(;;)
{
// The first thing is to check what state the decl is
@@ -757,6 +760,8 @@ namespace Slang
// cannot affect the state in which the declaration is *checked*.
//
SemanticsContext subContext = baseContext ? SemanticsContext(*baseContext) : SemanticsContext(getShared());
+ if (outerScope)
+ subContext = subContext.withOuterScope(outerScope);
_dispatchDeclCheckingVisitor(decl, nextState, subContext);
// In the common case, the visitor will have done the necessary
@@ -1245,6 +1250,8 @@ namespace Slang
}
}
}
+
+ checkVisibility(varDecl);
}
void SemanticsDeclHeaderVisitor::visitStructDecl(StructDecl* structDecl)
@@ -1261,11 +1268,12 @@ namespace Slang
{
addModifier(structDecl, m_astBuilder->create<NVAPIMagicModifier>());
}
+ checkVisibility(structDecl);
}
void SemanticsDeclHeaderVisitor::visitClassDecl(ClassDecl* classDecl)
{
- SLANG_UNUSED(classDecl);
+ checkVisibility(classDecl);
}
void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
@@ -1313,6 +1321,7 @@ namespace Slang
OverloadResolveContext overloadContext;
overloadContext.loc = varDecl->nameAndLoc.loc;
overloadContext.mode = OverloadResolveContext::Mode::JustTrying;
+ overloadContext.sourceScope = m_outerScope;
AddTypeOverloadCandidates(type, overloadContext);
if(overloadContext.bestCandidates.getCount() != 0)
@@ -1368,6 +1377,24 @@ namespace Slang
}
}
+ void addVisibilityModifier(ASTBuilder* builder, Decl* decl, DeclVisibility vis)
+ {
+ switch (vis)
+ {
+ case DeclVisibility::Public:
+ addModifier(decl, builder->create<PublicModifier>());
+ break;
+ case DeclVisibility::Internal:
+ addModifier(decl, builder->create<InternalModifier>());
+ break;
+ case DeclVisibility::Private:
+ addModifier(decl, builder->create<PrivateModifier>());
+ break;
+ default:
+ break;
+ }
+ }
+
bool SemanticsVisitor::trySynthesizeDifferentialAssociatedTypeRequirementWitness(
ConformanceCheckingContext* context,
DeclRef<AssocTypeDecl> requirementDeclRef,
@@ -1434,6 +1461,10 @@ namespace Slang
diffField->checkState = DeclCheckState::SignatureChecked;
diffField->parentDecl = aggTypeDecl;
aggTypeDecl->members.add(diffField);
+
+ auto visibility = getDeclVisibility(member);
+ addVisibilityModifier(m_astBuilder, diffField, visibility);
+
aggTypeDecl->invalidateMemberDictionary();
// Inject a `DerivativeMember` modifier on the differential field to point to itself.
@@ -1539,6 +1570,15 @@ namespace Slang
addModifier(aggTypeDecl, m_astBuilder->create<SynthesizedModifier>());
+ // The visibility of synthesized decl should be the min of the parent decl and the requirement.
+ if (auto visModifier = requirementDeclRef.getDecl()->findModifier<VisibilityModifier>())
+ {
+ auto requirementVisibility = getDeclVisibility(requirementDeclRef.getDecl());
+ auto thisVisibility = getDeclVisibility(context->parentDecl);
+ auto visibility = Math::Min(thisVisibility, requirementVisibility);
+ addVisibilityModifier(m_astBuilder, aggTypeDecl, visibility);
+ }
+
// Synthesize the rest of IDifferential method conformances by recursively checking
// conformance on the synthesized decl.
checkAggTypeConformance(aggTypeDecl);
@@ -1890,6 +1930,7 @@ namespace Slang
DeclCheckState::ModifiersChecked,
DeclCheckState::ReadyForReference,
DeclCheckState::ReadyForLookup,
+ DeclCheckState::ReadyForConformances,
DeclCheckState::Checked
};
for(auto s : states)
@@ -2810,6 +2851,7 @@ namespace Slang
{
synFuncDecl->nameAndLoc.name = getSession()->getNameObj("$__syn_" + synFuncDecl->nameAndLoc.name->text);
}
+
// The result type of our synthesized method will be the expected
// result type from the interface requirement.
//
@@ -2933,6 +2975,14 @@ namespace Slang
auto attr = m_astBuilder->create<BackwardDifferentiableAttribute>();
addModifier(synFuncDecl, attr);
}
+ // The visibility of synthesized decl should be the min of the parent decl and the requirement.
+ if (auto visModifier = requiredMemberDeclRef.getDecl()->findModifier<VisibilityModifier>())
+ {
+ auto requirementVisibility = getDeclVisibility(requiredMemberDeclRef.getDecl());
+ auto thisVisibility = getDeclVisibility(context->parentDecl);
+ auto visibility = Math::Min(thisVisibility, requirementVisibility);
+ addVisibilityModifier(m_astBuilder, synFuncDecl, visibility);
+ }
}
return synFuncDecl;
@@ -3471,6 +3521,15 @@ namespace Slang
synPropertyDecl->parentDecl = context->parentDecl;
+ // The visibility of synthesized decl should be the min of the parent decl and the requirement.
+ if (auto visModifier = requiredMemberDeclRef.getDecl()->findModifier<VisibilityModifier>())
+ {
+ auto requirementVisibility = getDeclVisibility(requiredMemberDeclRef.getDecl());
+ auto thisVisibility = getDeclVisibility(context->parentDecl);
+ auto visibility = Math::Min(thisVisibility, requirementVisibility);
+ addVisibilityModifier(m_astBuilder, synPropertyDecl, visibility);
+ }
+
// Once our synthesized declaration is complete, we need
// to install it as the witness that satifies the given
// requirement.
@@ -3969,7 +4028,7 @@ namespace Slang
// requests will be handled further down. For now we include
// lookup results that might be usable, but not as-is.
//
- auto lookupResult = lookUpMember(m_astBuilder, this, name, subType, LookupMask::Default, LookupOptions::IgnoreBaseInterfaces);
+ auto lookupResult = lookUpMember(m_astBuilder, this, name, subType, nullptr, LookupMask::Default, LookupOptions::IgnoreBaseInterfaces);
if(!lookupResult.isValid())
{
@@ -4502,6 +4561,8 @@ namespace Slang
void SemanticsDeclBasesVisitor::visitInterfaceDecl(InterfaceDecl* decl)
{
+ SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(this, decl);
+ checkVisibility(decl);
for( auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>() )
{
ensureDecl(inheritanceDecl, DeclCheckState::CanUseBaseOfInheritanceDecl);
@@ -4567,6 +4628,8 @@ namespace Slang
// Furthermore, only the first inheritance clause (in source
// order) is allowed to declare a base `struct` type.
//
+ SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(this, decl);
+
Index inheritanceClauseCounter = 0;
for( auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>() )
{
@@ -4636,6 +4699,7 @@ namespace Slang
// Furthermore, only the first inheritance clause (in source
// order) is allowed to declare a base `class` type.
//
+ SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(this, decl);
Index inheritanceClauseCounter = 0;
for (auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>())
{
@@ -4768,6 +4832,9 @@ namespace Slang
void SemanticsDeclBasesVisitor::visitEnumDecl(EnumDecl* decl)
{
+ SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(this, decl);
+ checkVisibility(decl);
+
// An `enum` type can inherit from interfaces, and also
// from a single "tag" type that must:
//
@@ -4775,7 +4842,6 @@ namespace Slang
// * come first in the list of base types
//
Index inheritanceClauseCounter = 0;
-
Type* tagType = nullptr;
InheritanceDecl* tagTypeInheritanceDecl = nullptr;
for(auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>())
@@ -4938,6 +5004,8 @@ namespace Slang
void SemanticsDeclBodyVisitor::visitEnumDecl(EnumDecl* decl)
{
+ SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(this, decl);
+
auto enumType = DeclRefType::create(m_astBuilder, makeDeclRef(decl));
auto tagType = decl->tagType;
@@ -5063,6 +5131,7 @@ namespace Slang
void SemanticsDeclHeaderVisitor::visitTypeDefDecl(TypeDefDecl* decl)
{
decl->type = CheckProperType(decl->type);
+ checkVisibility(decl);
}
void SemanticsDeclHeaderVisitor::visitGlobalGenericParamDecl(GlobalGenericParamDecl* decl)
@@ -5079,6 +5148,7 @@ namespace Slang
auto interfaceDecl = as<InterfaceDecl>(decl->parentDecl);
if (!interfaceDecl)
getSink()->diagnose(decl, Slang::Diagnostics::assocTypeInInterfaceOnly);
+ checkVisibility(decl);
}
void SemanticsDeclBodyVisitor::visitFunctionDeclBase(FunctionDeclBase* decl)
@@ -6154,6 +6224,7 @@ namespace Slang
}
}
}
+ checkVisibility(decl);
}
void SemanticsDeclHeaderVisitor::visitFuncDecl(FuncDecl* funcDecl)
@@ -6464,6 +6535,7 @@ namespace Slang
{
decl->type = CheckUsableType(decl->type);
visitAbstractStorageDeclCommon(decl);
+ checkVisibility(decl);
}
Type* SemanticsDeclHeaderVisitor::_getAccessorStorageType(AccessorDecl* decl)
@@ -6768,13 +6840,19 @@ namespace Slang
importedModulesList.add(moduleDecl);
importedModulesSet.add(moduleDecl);
- // Create a new sub-scope to wire the module
+ // Create a new sub-scope to wire the module's scope and its nested FileDecl's scopes
// into our lookup chain.
- auto subScope = getASTBuilder()->create<Scope>();
- subScope->containerDecl = moduleDecl;
+ for (auto moduleScope = moduleDecl->ownedScope; moduleScope; moduleScope = moduleScope->nextSibling)
+ {
+ if (moduleScope->containerDecl != moduleDecl && moduleScope->containerDecl->parentDecl != moduleDecl)
+ continue;
- subScope->nextSibling = scope->nextSibling;
- scope->nextSibling = subScope;
+ auto subScope = getASTBuilder()->create<Scope>();
+ subScope->containerDecl = moduleScope->containerDecl;
+
+ subScope->nextSibling = scope->nextSibling;
+ scope->nextSibling = subScope;
+ }
// Also import any modules from nested `import` declarations
// with the `__exported` modifier
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 7edf27b30..dd868f70c 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -225,6 +225,20 @@ namespace Slang
return expr;
}
+ Scope* SemanticsVisitor::getScope(SyntaxNode* node)
+ {
+ while (auto declBase = as<Decl>(node))
+ {
+ if (auto container = as<ContainerDecl>(node))
+ {
+ if (container->ownedScope)
+ return container->ownedScope;
+ }
+ node = declBase->parentDecl;
+ }
+ return nullptr;
+ }
+
static SourceLoc _getMemberOpLoc(Expr* expr)
{
if (auto m = as<MemberExpr>(expr))
@@ -794,6 +808,121 @@ namespace Slang
}
}
+ DeclVisibility SemanticsVisitor::getDeclVisibility(Decl* decl)
+ {
+ if (as<GenericTypeParamDecl>(decl) || as<GenericValueParamDecl>(decl) || as<GenericTypeConstraintDecl>(decl))
+ {
+ auto genericDecl = as<GenericDecl>(decl->parentDecl);
+ if (!genericDecl)
+ return DeclVisibility::Default;
+ if (genericDecl->inner)
+ return getDeclVisibility(genericDecl->inner);
+ return DeclVisibility::Default;
+ }
+ if (auto genericDecl = as<GenericDecl>(decl))
+ decl = genericDecl->inner;
+ for (; decl; decl = getParentDecl(decl))
+ {
+ if (as<AccessorDecl>(decl))
+ continue;
+ if (as<EnumCaseDecl>(decl))
+ continue;
+ break;
+ }
+ if (!decl)
+ return DeclVisibility::Public;
+
+ for (auto modifier : decl->modifiers)
+ {
+ if (as<PublicModifier>(modifier))
+ return DeclVisibility::Public;
+ else if (as<InternalModifier>(modifier))
+ return DeclVisibility::Internal;
+ else if (as<PrivateModifier>(modifier))
+ return DeclVisibility::Private;
+ }
+
+ if (auto parentModule = getModuleDecl(decl))
+ return parentModule->isInLegacyLanguage ? DeclVisibility::Public : DeclVisibility::Internal;
+
+ return DeclVisibility::Default;
+ }
+
+ DeclVisibility SemanticsVisitor::getTypeVisibility(Type* type)
+ {
+ if (auto declRefType = as<DeclRefType>(type))
+ {
+ auto v = getDeclVisibility(declRefType->getDeclRef().getDecl());
+ auto args = findInnerMostGenericArgs(SubstitutionSet(declRefType->getDeclRef()));
+ for (auto arg : args)
+ {
+ if (auto typeArg = as<DeclRefType>(arg))
+ v = Math::Min(v, getTypeVisibility(typeArg));
+ }
+ return v;
+ }
+ return DeclVisibility::Public;
+ }
+
+ bool SemanticsVisitor::isDeclVisibleFromScope(DeclRef<Decl> declRef, Scope* scope)
+ {
+ auto visibility = getDeclVisibility(declRef.getDecl());
+ if (visibility == DeclVisibility::Public)
+ return true;
+ if (visibility == DeclVisibility::Internal)
+ {
+ // Check that the decl is in the same module as the scope.
+ auto declModule = getModuleDecl(declRef.getDecl());
+ if (declModule == getModuleDecl(scope))
+ return true;
+ }
+ if (visibility == DeclVisibility::Private)
+ {
+ // Check that the decl is in the same or parent container decl as scope.
+ Decl* parentContainer = declRef.getDecl();
+ for (;parentContainer; parentContainer = parentContainer->parentDecl)
+ {
+ if (as<AggTypeDeclBase>(parentContainer))
+ break;
+ if (as<NamespaceDeclBase>(parentContainer))
+ break;
+ }
+
+ for (auto s = scope; s; s = s->parent)
+ {
+ if (s->containerDecl == parentContainer)
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+ LookupResult SemanticsVisitor::filterLookupResultByVisibility(const LookupResult& lookupResult)
+ {
+ if (!m_outerScope)
+ return lookupResult;
+ LookupResult filteredResult;
+ for (auto item : lookupResult)
+ {
+ if (isDeclVisibleFromScope(item.declRef, m_outerScope))
+ AddToLookupResult(filteredResult, item);
+ }
+ return filteredResult;
+ }
+
+ LookupResult SemanticsVisitor::filterLookupResultByVisibilityAndDiagnose(const LookupResult& lookupResult, SourceLoc loc, bool& outDiagnosed)
+ {
+ outDiagnosed = false;
+ auto result = filterLookupResultByVisibility(lookupResult);
+ if (lookupResult.isValid() && !result.isValid())
+ {
+ getSink()->diagnose(loc, Diagnostics::declIsNotVisible, lookupResult.item.declRef);
+ outDiagnosed = true;
+ }
+ return result;
+ }
+
LookupResult SemanticsVisitor::resolveOverloadedLookup(LookupResult const& inResult)
{
// If the result isn't actually overloaded, it is fine as-is
@@ -987,6 +1116,7 @@ namespace Slang
this,
getName("Differential"),
type,
+ nullptr,
Slang::LookupMask::type,
Slang::LookupOptions::None);
@@ -1141,7 +1271,7 @@ namespace Slang
// a scope in place. If we do, we will re-use it for any sub-expressions.
// If not, we need to create one.
//
- if(getExprLocalScope())
+ if (getExprLocalScope())
{
return dispatchExpr(term, *this);
}
@@ -1860,11 +1990,15 @@ namespace Slang
this,
operatorName,
baseType,
+ m_outerScope,
LookupMask::Default,
LookupOptions::NoDeref);
+ bool diagnosed = false;
+ lookupResult = filterLookupResultByVisibilityAndDiagnose(lookupResult, subscriptExpr->loc, diagnosed);
if (!lookupResult.isValid())
{
- getSink()->diagnose(subscriptExpr, Diagnostics::subscriptNonArray, baseType);
+ if (!diagnosed)
+ getSink()->diagnose(subscriptExpr, Diagnostics::subscriptNonArray, baseType);
return CreateErrorExpr(subscriptExpr);
}
auto subscriptFuncExpr = createLookupResultExpr(
@@ -2333,6 +2467,9 @@ namespace Slang
auto lookupResult = lookUp(
m_astBuilder,
this, expr->name, expr->scope);
+
+ bool diagnosed = false;
+ lookupResult = filterLookupResultByVisibilityAndDiagnose(lookupResult, expr->loc, diagnosed);
if (expr->name == getSession()->getCompletionRequestTokenName())
{
@@ -2353,7 +2490,8 @@ namespace Slang
expr);
}
- getSink()->diagnose(expr, Diagnostics::undefinedIdentifier2, expr->name);
+ if (!diagnosed)
+ getSink()->diagnose(expr, Diagnostics::undefinedIdentifier2, expr->name);
return expr;
}
@@ -3387,161 +3525,183 @@ namespace Slang
Expr* SemanticsVisitor::_lookupStaticMember(DeclRefExpr* expr, Expr* baseExpression)
{
- auto& baseType = baseExpression->type;
+ LookupResult globalLookupResult;
+ bool hasErrors = false;
+ Expr* base = nullptr;
+ auto handleLeafCase = [&](DeclRef<Decl> baseDeclRef, Type* type)
+ {
+ auto aggTypeDeclRef = as<AggTypeDeclBase>(baseDeclRef);
- // TODO: Need to handle overloaded case (in case we
- // have multiple visible types and/or namespaces
- // with the same name).
+ if (auto namespaceDeclRef = as<NamespaceDeclBase>(baseDeclRef))
+ {
+ // We are looking up a namespace member.
+ //
+ // This ought to be the easy case, because
+ // there are no restrictions on whether
+ // we can reference the declaration here.
+ //
+ LookupResult nsLookupResult = lookUpDirectAndTransparentMembers(
+ m_astBuilder,
+ this,
+ expr->name,
+ namespaceDeclRef.getDecl(),
+ namespaceDeclRef);
+ AddToLookupResult(globalLookupResult, nsLookupResult);
- if (auto namespaceType = as<NamespaceType>(baseType))
- {
- // We are looking up a namespace member.
- //
- auto namespaceDeclRef = namespaceType->getDeclRef();
+ }
+ else if (aggTypeDeclRef || type)
+ {
+ // We are looking up a member inside a type.
+ // We want to be careful here because we should only find members
+ // that are implicitly or explicitly `static`.
+ //
+ if (type == nullptr)
+ type = DeclRefType::create(m_astBuilder, aggTypeDeclRef);
- // This ought to be the easy case, because
- // there are no restrictions on whether
- // we can reference the declaration here.
- //
- LookupResult lookupResult = lookUpDirectAndTransparentMembers(
- m_astBuilder,
- this,
- expr->name,
- namespaceDeclRef.getDecl(),
- namespaceDeclRef);
- if (!lookupResult.isValid())
- {
- return lookupMemberResultFailure(expr, baseType);
- }
+ if (as<ErrorType>(type))
+ {
+ return;
+ }
- if (expr->name == getSession()->getCompletionRequestTokenName())
- {
- suggestCompletionItems(CompletionSuggestions::ScopeKind::Member, lookupResult);
- }
- return createLookupResultExpr(
- expr->name,
- lookupResult,
- nullptr,
- expr->loc,
- expr);
- }
- else if (auto typeType = as<TypeType>(baseType))
- {
- // We are looking up a member inside a type.
- // We want to be careful here because we should only find members
- // that are implicitly or explicitly `static`.
- //
- // TODO: this duplicates a *lot* of logic with the case below.
- // We need to fix that.
- auto type = typeType->getType();
+ LookupResult lookupResult = lookUpMember(
+ m_astBuilder,
+ this,
+ expr->name,
+ type,
+ m_outerScope);
- if (as<ErrorType>(type))
- {
- return CreateErrorExpr(expr);
- }
+ // We need to confirm that whatever member we
+ // are trying to refer to is usable via static reference.
+ //
+ // TODO: eventually we might allow a non-static
+ // member to be adapted by turning it into something
+ // like a closure that takes the missing `this` parameter.
+ //
+ // E.g., a static reference to a method could be treated
+ // as a value with a function type, where the first parameter
+ // is `type`.
+ //
+ // The biggest challenge there is that we'd need to arrange
+ // to generate "dispatcher" functions that could be used
+ // to implement that function, in the case where we are
+ // making a static reference to some kind of polymorphic declaration.
+ //
+ // (Also, static references to fields/properties would get even
+ // harder, because you'd have to know whether a getter/setter/ref-er
+ // is needed).
+ //
+ // For now let's just be expedient and disallow all of that, because
+ // we can always add it back in later.
- LookupResult lookupResult = lookUpMember(
- m_astBuilder,
- this,
- expr->name,
- type);
- if (!lookupResult.isValid())
- {
- return lookupMemberResultFailure(expr, baseType);
- }
+ // If the lookup result is valid, then we want to filter
+ // it to just those candidates that can be referenced statically,
+ // and ignore any that would only be allowed as instance members.
+ //
+ if (lookupResult.isValid())
+ {
+ // We track both the usable items, and whether or
+ // not there were any non-static items that need
+ // to be ignored.
+ //
+ bool anyNonStatic = false;
+ List<LookupResultItem> staticItems;
+ for (auto item : lookupResult)
+ {
+ // Is this item usable as a static member?
+ if (isUsableAsStaticMember(item))
+ {
+ // If yes, then it will be part of the output.
+ staticItems.add(item);
+ }
+ else
+ {
+ // If no, then we might need to output an error.
+ anyNonStatic = true;
+ }
+ }
- // We need to confirm that whatever member we
- // are trying to refer to is usable via static reference.
- //
- // TODO: eventually we might allow a non-static
- // member to be adapted by turning it into something
- // like a closure that takes the missing `this` parameter.
- //
- // E.g., a static reference to a method could be treated
- // as a value with a function type, where the first parameter
- // is `type`.
- //
- // The biggest challenge there is that we'd need to arrange
- // to generate "dispatcher" functions that could be used
- // to implement that function, in the case where we are
- // making a static reference to some kind of polymorphic declaration.
- //
- // (Also, static references to fields/properties would get even
- // harder, because you'd have to know whether a getter/setter/ref-er
- // is needed).
- //
- // For now let's just be expedient and disallow all of that, because
- // we can always add it back in later.
+ // Was there anything non-static in the list?
+ if (anyNonStatic)
+ {
+ // If we had some static items, then that's okay,
+ // we just want to use our newly-filtered list.
+ if (staticItems.getCount())
+ {
+ lookupResult.items = staticItems;
+ lookupResult.item = staticItems[0];
+ }
+ else
+ {
+ // Otherwise, it is time to report an error.
+ getSink()->diagnose(
+ expr->loc,
+ Diagnostics::staticRefToNonStaticMember,
+ type,
+ expr->name);
+ hasErrors = true;
+ return;
+ }
+ }
+ // If there were no non-static items, then the `items`
+ // array already represents what we'd get by filtering...
- // If the lookup result is valid, then we want to filter
- // it to just those candidates that can be referenced statically,
- // and ignore any that would only be allowed as instance members.
- //
- if(lookupResult.isValid())
- {
- // We track both the usable items, and whether or
- // not there were any non-static items that need
- // to be ignored.
- //
- bool anyNonStatic = false;
- List<LookupResultItem> staticItems;
- for (auto item : lookupResult)
- {
- // Is this item usable as a static member?
- if (isUsableAsStaticMember(item))
- {
- // If yes, then it will be part of the output.
- staticItems.add(item);
- }
- else
- {
- // If no, then we might need to output an error.
- anyNonStatic = true;
+ AddToLookupResult(globalLookupResult, lookupResult);
+ base = baseExpression;
}
}
+ };
- // Was there anything non-static in the list?
- if (anyNonStatic)
- {
- // If we had some static items, then that's okay,
- // we just want to use our newly-filtered list.
- if (staticItems.getCount())
- {
- lookupResult.items = staticItems;
- lookupResult.item = staticItems[0];
- }
- else
- {
- // Otherwise, it is time to report an error.
- getSink()->diagnose(
- expr->loc,
- Diagnostics::staticRefToNonStaticMember,
- type,
- expr->name);
- return CreateErrorExpr(expr);
- }
- }
- // If there were no non-static items, then the `items`
- // array already represents what we'd get by filtering...
- }
- if (expr->name == getSession()->getCompletionRequestTokenName())
+ auto handleLeafExpr = [&](Expr* e)
{
- suggestCompletionItems(CompletionSuggestions::ScopeKind::Member, lookupResult);
+ if (auto nsType = as<NamespaceType>(e->type))
+ handleLeafCase(nsType->getDeclRef(), nsType);
+ else if (auto aggType = as<DeclRefType>(e->type))
+ handleLeafCase(aggType->getDeclRef(), aggType);
+ else if (auto typetype = as<TypeType>(e->type))
+ handleLeafCase(DeclRef<Decl>(), typetype->getType());
+ };
+
+ auto& baseType = baseExpression->type;
+ if (as<ErrorType>(baseType))
+ {
+ return CreateErrorExpr(expr);
+ }
+
+ if (auto overloaded = as<OverloadedExpr>(baseExpression))
+ {
+ for (auto candidate : overloaded->lookupResult2.items)
+ handleLeafCase(candidate.declRef, nullptr);
+ }
+ else if (auto overloaded2 = as<OverloadedExpr2>(baseExpression))
+ {
+ for (auto candidate : overloaded2->candidiateExprs)
+ {
+ handleLeafExpr(candidate);
}
- return createLookupResultExpr(
- expr->name,
- lookupResult,
- baseExpression,
- expr->loc,
- expr);
}
- else if (as<ErrorType>(baseType))
+ else
{
- return CreateErrorExpr(expr);
+ handleLeafExpr(baseExpression);
+ }
+
+ bool diagnosed = false;
+ globalLookupResult = filterLookupResultByVisibilityAndDiagnose(globalLookupResult, expr->loc, diagnosed);
+ diagnosed |= hasErrors;
+ if (!globalLookupResult.isValid())
+ {
+ return lookupMemberResultFailure(expr, baseType, diagnosed);
}
- // Failure
- return lookupMemberResultFailure(expr, baseType);
+ if (expr->name == getSession()->getCompletionRequestTokenName())
+ {
+ suggestCompletionItems(CompletionSuggestions::ScopeKind::Member, globalLookupResult);
+ }
+ return createLookupResultExpr(
+ expr->name,
+ globalLookupResult,
+ base,
+ expr->loc,
+ expr);
}
Expr* SemanticsExprVisitor::visitStaticMemberExpr(StaticMemberExpr* expr)
@@ -3565,12 +3725,14 @@ namespace Slang
Expr* SemanticsVisitor::lookupMemberResultFailure(
DeclRefExpr* expr,
- QualType const& baseType)
+ QualType const& baseType,
+ bool supressDiagnostic)
{
// Check it's a member expression
SLANG_ASSERT(as<StaticMemberExpr>(expr) || as<MemberExpr>(expr));
- getSink()->diagnose(expr, Diagnostics::noMemberOfNameInType, expr->name, baseType);
+ if (!supressDiagnostic)
+ getSink()->diagnose(expr, Diagnostics::noMemberOfNameInType, expr->name, baseType);
expr->type = QualType(m_astBuilder->getErrorType());
return expr;
}
@@ -3678,6 +3840,14 @@ namespace Slang
{
return _lookupStaticMember(expr, expr->baseExpression);
}
+ else if (as<OverloadedExpr>(expr->baseExpression))
+ {
+ return _lookupStaticMember(expr, expr->baseExpression);
+ }
+ else if (as<OverloadedExpr2>(expr->baseExpression))
+ {
+ return _lookupStaticMember(expr, expr->baseExpression);
+ }
else if (as<ErrorType>(baseType))
{
return CreateErrorExpr(expr);
@@ -3688,10 +3858,13 @@ namespace Slang
m_astBuilder,
this,
expr->name,
- baseType.Ptr());
+ baseType.Ptr(),
+ m_outerScope);
+ bool diagnosed = false;
+ lookupResult = filterLookupResultByVisibilityAndDiagnose(lookupResult, expr->loc, diagnosed);
if (!lookupResult.isValid())
{
- return lookupMemberResultFailure(expr, baseType);
+ return lookupMemberResultFailure(expr, baseType, diagnosed);
}
if (expr->name == getSession()->getCompletionRequestTokenName())
{
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index e9654830a..43844cf70 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -217,6 +217,7 @@ namespace Slang
FixityChecked,
TypeChecked,
DirectionChecked,
+ VisibilityChecked,
Applicable,
};
Status status = Status::Unchecked;
@@ -773,6 +774,8 @@ namespace Slang
struct SemanticsContext
{
public:
+ friend struct OuterScopeContextRAII;
+
explicit SemanticsContext(
SharedSemanticsContext* shared)
: m_shared(shared)
@@ -804,6 +807,8 @@ namespace Slang
result.m_parentFunc = parentFunc;
result.m_outerStmts = nullptr;
result.m_parentDifferentiableAttr = parentFunc->findModifier<DifferentiableAttribute>();
+ if (parentFunc->ownedScope)
+ result.m_outerScope = parentFunc->ownedScope;
return result;
}
@@ -868,6 +873,7 @@ namespace Slang
};
ExprLocalScope* getExprLocalScope() { return m_exprLocalScope; }
+ Scope* getOuterScope() { return m_outerScope; }
SemanticsContext withExprLocalScope(ExprLocalScope* exprLocalScope)
{
@@ -876,6 +882,13 @@ namespace Slang
return result;
}
+ SemanticsContext withOuterScope(Scope* scope)
+ {
+ SemanticsContext result(*this);
+ result.m_outerScope = scope;
+ return result;
+ }
+
SemanticsContext withTreatAsDifferentiable(TreatAsDifferentiableExpr* expr)
{
SemanticsContext result(*this);
@@ -921,8 +934,31 @@ namespace Slang
TreatAsDifferentiableExpr* m_treatAsDifferentiableExpr = nullptr;
ASTBuilder* m_astBuilder = nullptr;
+
+ Scope* m_outerScope = nullptr;
+ };
+
+ struct OuterScopeContextRAII
+ {
+ SemanticsContext* m_context;
+ Scope* m_oldOuterScope;
+
+ OuterScopeContextRAII(SemanticsContext* context, Scope* outerScope)
+ : m_context(context)
+ , m_oldOuterScope(context->getOuterScope())
+ {
+ context->m_outerScope = outerScope;
+ }
+
+ ~OuterScopeContextRAII()
+ {
+ m_context->m_outerScope = m_oldOuterScope;
+ }
};
+#define SLANG_OUTER_SCOPE_CONTEXT_RAII(context, scope) OuterScopeContextRAII _outerScopeContextRAII(context, scope)
+#define SLANG_OUTER_SCOPE_CONTEXT_DECL_RAII(context, decl) OuterScopeContextRAII _outerScopeContextRAII(context, decl->ownedScope?decl->ownedScope:context->getOuterScope())
+
struct SemanticsVisitor : public SemanticsContext
{
typedef SemanticsContext Super;
@@ -1010,6 +1046,8 @@ namespace Slang
/// If `expr` has Ref<T> Type, convert it into an l-value expr that has T type.
Expr* maybeOpenRef(Expr* expr);
+ Scope* getScope(SyntaxNode* node);
+
void diagnoseDeprecatedDeclRefUsage(DeclRef<Decl> declRef, SourceLoc loc, Expr* originalExpr);
DeclRef<Decl> getDefaultDeclRef(Decl* decl)
@@ -1056,6 +1094,11 @@ namespace Slang
SourceLoc loc,
Expr* originalExpr);
+ DeclVisibility getDeclVisibility(Decl* decl);
+ DeclVisibility getTypeVisibility(Type* type);
+ bool isDeclVisibleFromScope(DeclRef<Decl> declRef, Scope* scope);
+ LookupResult filterLookupResultByVisibility(const LookupResult& lookupResult);
+ LookupResult filterLookupResultByVisibilityAndDiagnose(const LookupResult& lookupResult, SourceLoc loc, bool& outDiagnosed);
Val* resolveVal(Val* val)
{
@@ -1444,6 +1487,7 @@ namespace Slang
ModifiableSyntaxNode* syntaxNode);
void checkModifiers(ModifiableSyntaxNode* syntaxNode);
+ void checkVisibility(Decl* decl);
bool doesSignatureMatchRequirement(
DeclRef<CallableDecl> satisfyingMemberDeclRef,
@@ -1985,6 +2029,9 @@ namespace Slang
// Source location of the "function" part of the expression, if any
SourceLoc funcLoc;
+ // The source scope of the lookup for performing visibiliity tests.
+ Scope* sourceScope = nullptr;
+
// The original arguments to the call
Index argCount = 0;
Expr** args = nullptr;
@@ -2048,6 +2095,10 @@ namespace Slang
OverloadResolveContext& context,
OverloadCandidate const& candidate);
+ bool TryCheckOverloadCandidateVisibility(
+ OverloadResolveContext& context,
+ OverloadCandidate const& candidate);
+
bool TryCheckGenericOverloadCandidateTypes(
OverloadResolveContext& context,
OverloadCandidate& candidate);
@@ -2371,7 +2422,8 @@ namespace Slang
Expr* lookupMemberResultFailure(
DeclRefExpr* expr,
- QualType const& baseType);
+ QualType const& baseType,
+ bool supressDiagnostic = false);
SharedSemanticsContext& operator=(const SharedSemanticsContext &) = delete;
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index 569804ff4..339ecba4c 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -950,7 +950,7 @@ namespace Slang
{
if (auto parentExtension = as<ExtensionDecl>(varDecl->parentDecl))
{
- auto originalMemberLookup = lookUpMember(m_astBuilder, this, varDecl->getName(), parentExtension->targetType);
+ auto originalMemberLookup = lookUpMember(m_astBuilder, this, varDecl->getName(), parentExtension->targetType, parentExtension->ownedScope);
LookupResult filteredResult;
for (auto item : originalMemberLookup.items)
{
@@ -1042,6 +1042,23 @@ namespace Slang
}
}
+ if (as<PrivateModifier>(m))
+ {
+ if (as<AggTypeDeclBase>(syntaxNode) || as<NamespaceDeclBase>(syntaxNode))
+ {
+ getSink()->diagnose(m, Diagnostics::invalidUseOfPrivateVisibility, as<Decl>(syntaxNode));
+ }
+ else if (auto decl = as<Decl>(syntaxNode))
+ {
+ // Interface requirements can't be private.
+ if (isInterfaceRequirement(decl))
+ {
+ getSink()->diagnose(m, Diagnostics::invalidUseOfPrivateVisibility, as<Decl>(syntaxNode));
+ }
+ }
+ }
+
+
// Default behavior is to leave things as they are,
// and assume that modifiers are mostly already checked.
//
@@ -1054,6 +1071,71 @@ namespace Slang
return m;
}
+ void SemanticsVisitor::checkVisibility(Decl* decl)
+ {
+ if (as<AccessorDecl>(decl))
+ {
+ return;
+ }
+ ShortList<Type*> typesToVerify;
+ if (auto varDecl = as<VarDeclBase>(decl))
+ {
+ typesToVerify.add(varDecl->type);
+ }
+ else if (auto callable = as<CallableDecl>(decl))
+ {
+ typesToVerify.add(callable->returnType);
+ typesToVerify.add(callable->errorType);
+ for (auto param : callable->getParameters())
+ {
+ typesToVerify.add(param->type);
+ }
+ }
+ else if (auto propertyDecl = as<PropertyDecl>(decl))
+ {
+ typesToVerify.add(propertyDecl->type);
+ }
+ else if (as<AggTypeDeclBase>(decl))
+ {
+ }
+ else if (auto typeDecl = as<TypeDefDecl>(decl))
+ {
+ typesToVerify.add(typeDecl->type);
+ }
+ else
+ {
+ return;
+ }
+ auto thisVisibility = getDeclVisibility(decl);
+
+ // First, we check that the decl's type does not have lower visibility.
+ for (auto type : typesToVerify)
+ {
+ if (!type)
+ continue;
+ DeclVisibility typeVisibility = getTypeVisibility(type);
+ if (typeVisibility < thisVisibility)
+ {
+ getSink()->diagnose(decl, Diagnostics::useOfLessVisibleType, decl, type);
+ break;
+ }
+ }
+
+ // Next, we check that the decl does not have higher visiblity than its parent.
+ Decl* parentDecl = decl;
+ for (; parentDecl; parentDecl = parentDecl->parentDecl)
+ {
+ if (as<AggTypeDeclBase>(parentDecl))
+ break;
+ }
+ if (!parentDecl)
+ return;
+ auto parentVisibility = getDeclVisibility(parentDecl);
+ if (thisVisibility > parentVisibility)
+ {
+ getSink()->diagnose(decl, Diagnostics::declCannotHaveHigherVisibility, decl, parentDecl);
+ }
+ }
void SemanticsVisitor::checkModifiers(ModifiableSyntaxNode* syntaxNode)
{
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index d7d29a4e1..2912a79b0 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -190,6 +190,33 @@ namespace Slang
}
}
+ bool SemanticsVisitor::TryCheckOverloadCandidateVisibility(OverloadResolveContext& context, OverloadCandidate const& candidate)
+ {
+ // Always succeeds when we are trying out constructors.
+ if (context.mode == OverloadResolveContext::Mode::JustTrying)
+ {
+ if (as<ConstructorDecl>(candidate.item.declRef))
+ return true;
+ }
+
+ if (!context.sourceScope)
+ return true;
+
+ if (!candidate.item.declRef)
+ return true;
+
+ if (!isDeclVisibleFromScope(candidate.item.declRef, context.sourceScope))
+ {
+ if (context.mode == OverloadResolveContext::Mode::ForReal)
+ {
+ getSink()->diagnose(context.loc, Diagnostics::declIsNotVisible, candidate.item.declRef);
+ }
+ return false;
+ }
+
+ return true;
+ }
+
bool SemanticsVisitor::TryCheckGenericOverloadCandidateTypes(
OverloadResolveContext& context,
OverloadCandidate& candidate)
@@ -704,6 +731,10 @@ namespace Slang
if (!TryCheckOverloadCandidateConstraints(context, candidate))
return;
+ candidate.status = OverloadCandidate::Status::VisibilityChecked;
+ if (!TryCheckOverloadCandidateVisibility(context, candidate))
+ return;
+
candidate.status = OverloadCandidate::Status::Applicable;
}
@@ -777,6 +808,9 @@ namespace Slang
if (!TryCheckOverloadCandidateConstraints(context, candidate))
goto error;
+ if (!TryCheckOverloadCandidateVisibility(context, candidate))
+ goto error;
+
{
Expr* baseExpr;
switch(candidate.flavor)
@@ -887,7 +921,6 @@ namespace Slang
}
else
{
- SLANG_DIAGNOSE_UNEXPECTED(getSink(), context.loc, "no original expression for overload result");
return nullptr;
}
}
@@ -1511,6 +1544,7 @@ namespace Slang
this,
getName("$init"),
type,
+ context.sourceScope,
LookupMask::Default,
LookupOptions::NoDeref);
@@ -1885,7 +1919,7 @@ namespace Slang
context.argCount = expr->arguments.getCount();
context.args = expr->arguments.getBuffer();
context.loc = expr->loc;
-
+ context.sourceScope = m_outerScope;
context.baseExpr = GetBaseExpr(funcExpr);
// TODO: We should have a special case here where an `InvokeExpr`
@@ -1975,26 +2009,16 @@ namespace Slang
Index candidateCount = context.bestCandidates.getCount();
Index maxCandidatesToPrint = 10; // don't show too many candidates at once...
Index candidateIndex = 0;
+ context.bestCandidates.sort([](const OverloadCandidate& c1, const OverloadCandidate& c2) { return c1.status < c2.status; });
+
for (auto candidate : context.bestCandidates)
{
String declString = ASTPrinter::getDeclSignatureString(candidate.item, m_astBuilder);
-// declString = declString + "[" + String(candidate.conversionCostSum) + "]";
-
-#if 0
- // Debugging: ensure that we don't consider multiple declarations of the same operation
- if (auto decl = as<CallableDecl>(candidate.item.declRef.decl))
- {
- char buffer[1024];
- sprintf_s(buffer, sizeof(buffer), "[this:%p, primary:%p, next:%p]",
- decl,
- decl->primaryDecl,
- decl->nextDecl);
- declString.append(buffer);
- }
-#endif
-
- getSink()->diagnose(candidate.item.declRef, Diagnostics::overloadCandidate, declString);
+ if (candidate.status == OverloadCandidate::Status::VisibilityChecked)
+ getSink()->diagnose(candidate.item.declRef, Diagnostics::invisibleOverloadCandidate, declString);
+ else
+ getSink()->diagnose(candidate.item.declRef, Diagnostics::overloadCandidate, declString);
candidateIndex++;
if (candidateIndex == maxCandidatesToPrint)
@@ -2126,7 +2150,7 @@ namespace Slang
context.argCount = args.getCount();
context.args = args.getBuffer();
context.loc = genericAppExpr->loc;
-
+ context.sourceScope = m_outerScope;
context.baseExpr = GetBaseExpr(baseExpr);
AddGenericOverloadCandidates(baseExpr, context);
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 8eb0584d0..c95d5ea98 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -357,6 +357,13 @@ DIAGNOSTIC(30503, Error, primaryModuleFileCannotStartWithImplementingDecl, "a pr
DIAGNOSTIC(30504, Warning, primaryModuleFileMustStartWithModuleDecl, "a primary source file for a module should start with 'module'.")
DIAGNOSTIC(30505, Error, implementingMustReferencePrimaryModuleFile, "the source file referenced by 'implementing' must be a primary module file starting with a 'module' declaration.")
+// Visibilty
+DIAGNOSTIC(30600, Error, declIsNotVisible, "'$0' is not accessible from the current context.")
+DIAGNOSTIC(30601, Error, declCannotHaveHigherVisibility, "'$0' cannot have a higher visibility than '$1'.")
+DIAGNOSTIC(30602, Error, declCannotHaveLowerVisibility, "'$0' cannot have a lower visibility than '$1'.")
+DIAGNOSTIC(30603, Error, invalidUseOfPrivateVisibility, "'$0' cannot have private visibility.")
+DIAGNOSTIC(30604, Error, useOfLessVisibleType, "'$0' references less visible type '$1'.")
+
// Attributes
DIAGNOSTIC(31000, Error, unknownAttributeName, "unknown attribute '$0'")
DIAGNOSTIC(31001, Error, attributeArgumentCountMismatch, "attribute '$0' expects $1 arguments ($2 provided)")
@@ -502,6 +509,8 @@ DIAGNOSTIC(39999, Error, ambiguousOverloadForNameWithArgs, "ambiguous call to '$
DIAGNOSTIC(39999, Error, ambiguousOverloadWithArgs, "ambiguous call to overloaded operation with arguments of type $0")
DIAGNOSTIC(39999, Note, overloadCandidate, "candidate: $0")
+DIAGNOSTIC(39999, Note, invisibleOverloadCandidate, "candidate (invisible): $0")
+
DIAGNOSTIC(39999, Note, moreOverloadCandidates, "$0 more overload candidates")
DIAGNOSTIC(39999, Error, caseOutsideSwitch, "'case' not allowed outside of a 'switch' statement")
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index d0efce0f5..7f7e23a1c 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -4122,8 +4122,8 @@ void CLikeSourceEmitter::computeEmitActions(IRModule* module, List<EmitAction>&
{
if( as<IRType>(inst) )
{
- // Don't emit a type unless it is actually used or is marked public.
- if (!inst->findDecoration<IRPublicDecoration>())
+ // Don't emit a type unless it is actually used or is marked exported.
+ if (!inst->findDecoration<IRHLSLExportDecoration>())
continue;
}
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index e4f3f3f94..9166c560a 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -2066,20 +2066,15 @@ void releaseNullDifferentialType(AutoDiffSharedContext* context)
{
if (auto nullStruct = context->nullDifferentialStructType)
{
- if (auto publicDecoration = nullStruct->findDecoration<IRPublicDecoration>())
- publicDecoration->removeAndDeallocate();
if (auto keepAliveDecoration = nullStruct->findDecoration<IRKeepAliveDecoration>())
keepAliveDecoration->removeAndDeallocate();
}
if (auto nullWitness = context->nullDifferentialWitness)
{
- if (auto publicDecoration = nullWitness->findDecoration<IRPublicDecoration>())
- publicDecoration->removeAndDeallocate();
if (auto keepAliveDecoration = nullWitness->findDecoration<IRKeepAliveDecoration>())
keepAliveDecoration->removeAndDeallocate();
}
-
}
bool finalizeAutoDiffPass(IRModule* module)
diff --git a/source/slang/slang-ir-dll-export.cpp b/source/slang/slang-ir-dll-export.cpp
index d7a18e665..af5f70eb3 100644
--- a/source/slang/slang-ir-dll-export.cpp
+++ b/source/slang/slang-ir-dll-export.cpp
@@ -4,6 +4,7 @@
#include "slang-ir.h"
#include "slang-ir-insts.h"
#include "slang-ir-marshal-native-call.h"
+#include "slang-ir-util.h"
namespace Slang
{
@@ -26,10 +27,7 @@ struct DllExportContext
builder.addPublicDecoration(wrapper);
builder.addKeepAliveDecoration(wrapper);
builder.addHLSLExportDecoration(wrapper);
- if (auto oldPublicDecoration = func->findDecoration<IRPublicDecoration>())
- {
- oldPublicDecoration->removeFromParent();
- }
+ removeLinkageDecorations(func);
}
void processModule()
diff --git a/source/slang/slang-ir-generics-lowering-context.cpp b/source/slang/slang-ir-generics-lowering-context.cpp
index 325568040..212e16483 100644
--- a/source/slang/slang-ir-generics-lowering-context.cpp
+++ b/source/slang/slang-ir-generics-lowering-context.cpp
@@ -60,7 +60,7 @@ namespace Slang
return result;
IRBuilder builderStorage(module);
auto builder = &builderStorage;
- builder->setInsertBefore(typeInst->next);
+ builder->setInsertAfter(typeInst);
result = builder->emitMakeRTTIObject(typeInst);
@@ -75,10 +75,11 @@ namespace Slang
String rttiObjName = exportDecoration->getMangledName();
builder->addExportDecoration(result, rttiObjName.getUnownedSlice());
}
- // Make sure the RTTI object for a public struct type has public visiblity.
- if (typeInst->findDecoration<IRPublicDecoration>())
+
+ // Make sure the RTTI object for an exported struct type is marked as export if the type is.
+ if (typeInst->findDecoration<IRHLSLExportDecoration>())
{
- builder->addPublicDecoration(result);
+ builder->addHLSLExportDecoration(result);
builder->addKeepAliveDecoration(result);
}
mapTypeToRTTIObject[typeInst] = result;
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 87b4f3fde..36769cc34 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1412,13 +1412,12 @@ struct IRSpecializationState
}
};
-static bool _isPublicOrHLSLExported(IRInst* inst)
+static bool _isHLSLExported(IRInst* inst)
{
for (auto decoration : inst->getDecorations())
{
const auto op = decoration->getOp();
- if (op == kIROp_PublicDecoration ||
- op == kIROp_HLSLExportDecoration)
+ if (op == kIROp_HLSLExportDecoration)
{
return true;
}
@@ -1582,8 +1581,8 @@ LinkedIR linkIR(
{
for (auto inst : irModule->getGlobalInsts())
{
- // Is it `public` or (HLSL) `export` clone
- if (_isPublicOrHLSLExported(inst))
+ // Is it (HLSL) `export` clone
+ if (_isHLSLExported(inst))
{
auto cloned = cloneValue(context, inst);
if (!cloned->findDecorationImpl(kIROp_KeepAliveDecoration))
diff --git a/source/slang/slang-ir-lower-generic-type.cpp b/source/slang/slang-ir-lower-generic-type.cpp
index ae085145c..28eed3582 100644
--- a/source/slang/slang-ir-lower-generic-type.cpp
+++ b/source/slang/slang-ir-lower-generic-type.cpp
@@ -16,10 +16,10 @@ namespace Slang
IRInst* processInst(IRInst* inst)
{
- // Ensure public struct types has RTTI object defined.
+ // Ensure exported struct types has RTTI object defined.
if (as<IRStructType>(inst))
{
- if (inst->findDecoration<IRPublicDecoration>())
+ if (inst->findDecoration<IRHLSLExportDecoration>())
{
sharedContext->maybeEmitRTTIObject(inst);
}
diff --git a/source/slang/slang-ir-pytorch-cpp-binding.cpp b/source/slang/slang-ir-pytorch-cpp-binding.cpp
index 432cd93f3..6a85f0324 100644
--- a/source/slang/slang-ir-pytorch-cpp-binding.cpp
+++ b/source/slang/slang-ir-pytorch-cpp-binding.cpp
@@ -575,7 +575,7 @@ void generateReflectionFunc(IRBuilder* builder, IRFunc* kernelFunc, IRFunc* host
builder->addExternCppDecoration(reflectionFunc, reflFuncExportName.getUnownedSlice());
builder->addTorchEntryPointDecoration(reflectionFunc, reflFuncExportName.getUnownedSlice());
- builder->addPublicDecoration(reflectionFunc);
+ builder->addHLSLExportDecoration(reflectionFunc);
builder->addKeepAliveDecoration(reflectionFunc);
}
@@ -760,7 +760,7 @@ void generateReflectionForType(IRType* type, DiagnosticSink* sink)
builder.addTorchEntryPointDecoration(reflFunc, reflFuncExportName.getUnownedSlice());
builder.addExternCppDecoration(reflFunc, reflFuncExportName.getUnownedSlice());
- builder.addPublicDecoration(reflFunc);
+ builder.addHLSLExportDecoration(reflFunc);
builder.addKeepAliveDecoration(reflFunc);
}
@@ -842,7 +842,7 @@ IRFunc* generateCUDAWrapperForFunc(IRFunc* func, DiagnosticSink* sink)
// Mark for host-side emit logic.
builder.addCudaHostDecoration(hostFunc);
// Keep alive. This method will be accessed externally.
- builder.addPublicDecoration(hostFunc);
+ builder.addHLSLExportDecoration(hostFunc);
builder.addKeepAliveDecoration(hostFunc);
}
@@ -1047,7 +1047,7 @@ void generateDerivativeWrappers(IRModule* module, DiagnosticSink* sink)
builder.addExternCppDecoration(wrapperFunc, nameBuilder.getUnownedSlice());
}
- builder.addPublicDecoration(wrapperFunc);
+ builder.addHLSLExportDecoration(wrapperFunc);
builder.addKeepAliveDecoration(wrapperFunc);
builder.addCudaKernelForwardDerivativeDecoration(func, wrapperFunc);
@@ -1106,7 +1106,7 @@ void generateDerivativeWrappers(IRModule* module, DiagnosticSink* sink)
builder.addExternCppDecoration(wrapperFunc, nameBuilder.getUnownedSlice());
}
- builder.addPublicDecoration(wrapperFunc);
+ builder.addHLSLExportDecoration(wrapperFunc);
builder.addKeepAliveDecoration(wrapperFunc);
builder.addCudaKernelBackwardDerivativeDecoration(func, wrapperFunc);
diff --git a/source/slang/slang-language-server-completion.cpp b/source/slang/slang-language-server-completion.cpp
index 7b01dac34..6038a432a 100644
--- a/source/slang/slang-language-server-completion.cpp
+++ b/source/slang/slang-language-server-completion.cpp
@@ -298,7 +298,7 @@ SlangResult CompletionContext::tryCompleteImport()
Index pos = -1;
for (auto prefix : prefixes)
{
- static auto importStr = UnownedStringSlice(prefix);
+ auto importStr = UnownedStringSlice(prefix);
lineContent = doc->getLine(line);
pos = lineContent.indexOf(importStr);
if (pos == -1)
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp
index ee4518c20..04a855c3c 100644
--- a/source/slang/slang-lookup.cpp
+++ b/source/slang/slang-lookup.cpp
@@ -98,6 +98,19 @@ void AddToLookupResult(
}
}
+void AddToLookupResult(LookupResult& result, const LookupResult& items)
+{
+ if (items.isOverloaded())
+ {
+ for (auto item : items.items)
+ AddToLookupResult(result, item);
+ }
+ else if (items.isValid())
+ {
+ AddToLookupResult(result, items.item);
+ }
+}
+
LookupResult refineLookup(LookupResult const& inResult, LookupMask mask)
{
if (!inResult.isValid()) return inResult;
@@ -894,11 +907,12 @@ LookupResult lookUpMember(
SemanticsVisitor* semantics,
Name* name,
Type* type,
+ Scope* sourceScope,
LookupMask mask,
LookupOptions options)
{
LookupResult result;
- LookupRequest request = initLookupRequest(semantics, name, mask, options, nullptr);
+ LookupRequest request = initLookupRequest(semantics, name, mask, options, sourceScope);
_lookUpMembersInType(astBuilder, name, type, request, result, nullptr);
return result;
}
diff --git a/source/slang/slang-lookup.h b/source/slang/slang-lookup.h
index 8af760f70..84b453bf2 100644
--- a/source/slang/slang-lookup.h
+++ b/source/slang/slang-lookup.h
@@ -27,6 +27,7 @@ LookupResult lookUpMember(
SemanticsVisitor* semantics,
Name* name,
Type* type,
+ Scope* sourceScope,
LookupMask mask = LookupMask::Default,
LookupOptions options = LookupOptions::None);
@@ -58,7 +59,9 @@ QualType getTypeForDeclRef(
void AddToLookupResult(
LookupResult& result,
LookupResultItem item);
-
+void AddToLookupResult(
+ LookupResult& result,
+ const LookupResult& items);
}
#endif
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 609a5d1e5..8f94b7e90 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -1327,7 +1327,6 @@ static void addLinkageDecoration(
if (as<PublicModifier>(modifier))
{
builder->addPublicDecoration(inst);
- builder->addKeepAliveDecoration(inst);
}
else if (as<HLSLExportModifier>(modifier))
{
@@ -1349,43 +1348,50 @@ static void addLinkageDecoration(
else if (as<DllExportAttribute>(modifier))
{
builder->addDllExportDecoration(inst, decl->getName()->text.getUnownedSlice());
- builder->addPublicDecoration(inst);
+ builder->addHLSLExportDecoration(inst);
+ builder->addKeepAliveDecoration(inst);
}
else if (as<CudaDeviceExportAttribute>(modifier))
{
builder->addCudaDeviceExportDecoration(inst, decl->getName()->text.getUnownedSlice());
- builder->addPublicDecoration(inst);
+ builder->addHLSLExportDecoration(inst);
builder->addExternCppDecoration(inst, decl->getName()->text.getUnownedSlice());
+ builder->addKeepAliveDecoration(inst);
}
else if (as<CudaHostAttribute>(modifier))
{
builder->addCudaHostDecoration(inst);
builder->addExternCppDecoration(inst, decl->getName()->text.getUnownedSlice());
+ builder->addKeepAliveDecoration(inst);
}
else if (as<CudaKernelAttribute>(modifier))
{
builder->addCudaKernelDecoration(inst);
builder->addExternCppDecoration(inst, decl->getName()->text.getUnownedSlice());
- builder->addPublicDecoration(inst);
+ builder->addHLSLExportDecoration(inst);
builder->addKeepAliveDecoration(inst);
}
else if (as<TorchEntryPointAttribute>(modifier))
{
builder->addTorchEntryPointDecoration(inst, decl->getName()->text.getUnownedSlice());
builder->addCudaHostDecoration(inst);
- builder->addPublicDecoration(inst);
+ builder->addHLSLExportDecoration(inst);
+ builder->addKeepAliveDecoration(inst);
builder->addExternCppDecoration(inst, decl->getName()->text.getUnownedSlice());
}
else if (as<AutoPyBindCudaAttribute>(modifier))
{
builder->addAutoPyBindCudaDecoration(inst, decl->getName()->text.getUnownedSlice());
builder->addAutoPyBindExportInfoDecoration(inst);
+ builder->addKeepAliveDecoration(inst);
+ builder->addHLSLExportDecoration(inst);
}
else if (auto pyExportModifier = as<PyExportAttribute>(modifier))
{
builder->addPyExportDecoration(inst, pyExportModifier->name.getLength()
? pyExportModifier->name.getUnownedSlice()
: decl->getName()->text.getUnownedSlice());
+ builder->addHLSLExportDecoration(inst);
}
else if (auto knownBuiltinModifier = as<KnownBuiltinAttribute>(modifier))
{
@@ -7012,15 +7018,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
return LoweredValInfo::simple(inst);
}
- bool isPublicType(Type* type)
+ bool isExportedType(Type* type)
{
- // TODO(JS):
- // Not clear how should handle HLSLExportModifier here.
- // In the HLSL spec 'export' is only applicable to functions. So for now we ignore.
-
if (auto declRefType = as<DeclRefType>(type))
{
- if (declRefType->getDeclRef().getDecl()->findModifier<PublicModifier>())
+ if (declRefType->getDeclRef().getDecl()->findModifier<HLSLExportModifier>())
return true;
}
return false;
@@ -7077,9 +7079,9 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
astReqWitnessTable->witnessedType,
astReqWitnessTable->baseType);
subBuilder->addExportDecoration(irSatisfyingWitnessTable, mangledName.getUnownedSlice());
- if (isPublicType(astReqWitnessTable->witnessedType))
+ if (isExportedType(astReqWitnessTable->witnessedType))
{
- subBuilder->addPublicDecoration(irSatisfyingWitnessTable);
+ subBuilder->addHLSLExportDecoration(irSatisfyingWitnessTable);
subBuilder->addKeepAliveDecoration(irSatisfyingWitnessTable);
}
@@ -7219,17 +7221,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
subBuilder->addPublicDecoration(irWitnessTable);
}
- // TODO(JS):
- // Not clear what to do here around HLSLExportModifier.
- // In HLSL it only (currently) applies to functions, so perhaps do nothing is reasonable.
-
- if (parentDecl->findModifier<PublicModifier>())
+ if (parentDecl->findModifier<HLSLExportModifier>())
{
- subBuilder->addPublicDecoration(irWitnessTable);
+ subBuilder->addHLSLExportDecoration(irWitnessTable);
subBuilder->addKeepAliveDecoration(irWitnessTable);
}
-
// Make sure that all the entries in the witness table have been filled in,
// including any cases where there are sub-witness-tables for conformances
Dictionary<WitnessTable*, IRWitnessTable*> mapASTToIRWitnessTable;
@@ -10607,7 +10604,9 @@ struct TypeConformanceIRGenContext
context->irBuilder = builder;
auto witness = lowerSimpleVal(context, typeConformance->getSubtypeWitness());
- builder->addPublicDecoration(witness);
+ builder->addKeepAliveDecoration(witness);
+ builder->addHLSLExportDecoration(witness);
+
if (conformanceIdOverride != -1)
{
builder->addSequentialIDDecoration(witness, conformanceIdOverride);
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 350bc9443..7367007e6 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -105,6 +105,7 @@ namespace Slang
Scope* outerScope = nullptr;
Scope* currentScope = nullptr;
+ ModuleDecl* currentModule = nullptr;
bool hasSeenCompletionToken = false;
@@ -153,12 +154,7 @@ namespace Slang
ModuleDecl* getCurrentModuleDecl()
{
- for (auto scope = currentScope; scope; scope = scope->parent)
- {
- if (auto moduleDecl = as<ModuleDecl>(scope->containerDecl))
- return moduleDecl;
- }
- return nullptr;
+ return currentModule;
}
Parser(
@@ -1157,7 +1153,11 @@ namespace Slang
{
parsedModifier->loc = nameToken.loc;
}
-
+ if (as<VisibilityModifier>(parsedModifier))
+ {
+ if (auto currentModule = parser->getCurrentModuleDecl())
+ currentModule->isInLegacyLanguage = false;
+ }
AddModifier(&modifierLink, parsedModifier);
continue;
}
@@ -1262,6 +1262,8 @@ namespace Slang
{
auto decl = parser->astBuilder->create<IncludeDecl>();
parseFileReferenceDeclBase(parser, decl);
+ if (auto currentModule = parser->getCurrentModuleDecl())
+ currentModule->isInLegacyLanguage = false;
return decl;
}
@@ -1296,6 +1298,8 @@ namespace Slang
decl->nameAndLoc.loc = parser->tokenReader.peekLoc();
}
parser->ReadToken(TokenType::Semicolon);
+ if (auto currentModule = parser->getCurrentModuleDecl())
+ currentModule->isInLegacyLanguage = false;
return decl;
}
@@ -3063,6 +3067,9 @@ namespace Slang
// The first is a type declaration that holds all the members, while
// the second is a variable declaration that uses the buffer type.
StructDecl* bufferDataTypeDecl = parser->astBuilder->create<StructDecl>();
+
+ addModifier(bufferDataTypeDecl, parser->astBuilder->create<PublicModifier>());
+
VarDecl* bufferVarDecl = parser->astBuilder->create<VarDecl>();
// Both declarations will have a location that points to the name
@@ -3646,6 +3653,7 @@ namespace Slang
decl->nameAndLoc = declaratorInfo.nameAndLoc;
decl->type = TypeExp(declaratorInfo.typeSpec);
+ decl->loc = decl->nameAndLoc.loc;
}
parseStorageDeclBody(parser, decl);
@@ -4238,6 +4246,8 @@ namespace Slang
currentScope = outerScope;
}
+ currentModule = getModuleDecl(program);
+
PushScope(program);
// A single `ModuleDecl` might span multiple source files, so it
@@ -6997,7 +7007,7 @@ namespace Slang
syntaxDecl->syntaxClass = syntaxClass;
syntaxDecl->parseCallback = callback;
syntaxDecl->parseUserData = userData;
-
+ addModifier(syntaxDecl, globalASTBuilder->create<PublicModifier>());
AddMember(scope, syntaxDecl);
}
@@ -7511,6 +7521,9 @@ namespace Slang
_makeParseModifier("inline", InlineModifier::kReflectClassInfo),
_makeParseModifier("public", PublicModifier::kReflectClassInfo),
+ _makeParseModifier("private", PrivateModifier::kReflectClassInfo),
+ _makeParseModifier("internal", InternalModifier::kReflectClassInfo),
+
_makeParseModifier("require", RequireModifier::kReflectClassInfo),
_makeParseModifier("param", ParamModifier::kReflectClassInfo),
_makeParseModifier("extern", ExternModifier::kReflectClassInfo),
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index 53a02ed87..678d9ec26 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -765,6 +765,17 @@ Module* getModule(Decl* decl)
return moduleDecl->module;
}
+ModuleDecl* getModuleDecl(Scope* scope)
+{
+ for (; scope; scope = scope->parent)
+ {
+ if (scope->containerDecl)
+ return getModuleDecl(scope->containerDecl);
+ }
+ return nullptr;
+
+}
+
Decl* getParentDecl(Decl* decl)
{
decl = decl->parentDecl;
diff --git a/source/slang/slang-syntax.h b/source/slang/slang-syntax.h
index b2b5deb22..fff567049 100644
--- a/source/slang/slang-syntax.h
+++ b/source/slang/slang-syntax.h
@@ -330,6 +330,7 @@ namespace Slang
/// Get the module dclaration that a declaration is associated with, if any.
ModuleDecl* getModuleDecl(Decl* decl);
+ ModuleDecl* getModuleDecl(Scope* scope);
/// Get the module that a declaration is associated with, if any.
Module* getModule(Decl* decl);
diff --git a/tests/autodiff/bsdf/bsdf-auto-rev.slang b/tests/autodiff/bsdf/bsdf-auto-rev.slang
index cd31f2097..1bb1989bf 100644
--- a/tests/autodiff/bsdf/bsdf-auto-rev.slang
+++ b/tests/autodiff/bsdf/bsdf-auto-rev.slang
@@ -1,4 +1,5 @@
//TEST_IGNORE_FILE:
+implementing "bsdf-sample";
struct ShadingData
{
@@ -103,4 +104,4 @@ float bsdfGGXPDF(in float3 hLocal, in Auto_Bwd_BSDFParameters params)
float d = ((cosTheta * a2 - cosTheta) * cosTheta + 1);
return (a2 / (d * d * 3.1415926)) * cosTheta;
-} \ No newline at end of file
+}
diff --git a/tests/autodiff/bsdf/bsdf-sample.slang b/tests/autodiff/bsdf/bsdf-sample.slang
index 8a9508791..9dfecf97e 100644
--- a/tests/autodiff/bsdf/bsdf-sample.slang
+++ b/tests/autodiff/bsdf/bsdf-sample.slang
@@ -2,9 +2,10 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
-RWStructuredBuffer<float> outputBuffer;
+module "bsdf-sample";
+__include bsdf_auto_rev;
-__exported import bsdf_auto_rev;
+RWStructuredBuffer<float> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
diff --git a/tests/autodiff/cuda-kernel-export.slang b/tests/autodiff/cuda-kernel-export.slang
index 928133c94..39815ede8 100644
--- a/tests/autodiff/cuda-kernel-export.slang
+++ b/tests/autodiff/cuda-kernel-export.slang
@@ -35,7 +35,7 @@ void myKernel(TensorView<float> inValues, TensorView<float> outValues)
// TORCH: {{^SLANG_PRELUDE_EXPORT$}}
// TORCH-NEXT: std::tuple<std::tuple<float, float>, std::tuple<std::tuple<std::tuple<torch::Tensor, torch::Tensor>>, std::tuple<std::tuple<torch::Tensor, torch::Tensor>>>> runCompute(std::tuple<torch::Tensor, float> input_[[#]])
[TorchEntryPoint]
-public __extern_cpp MyType runCompute(MyInput input)
+export __extern_cpp MyType runCompute(MyInput input)
{
MyType rs;
var outValues = TorchTensor<float>.alloc(1);
diff --git a/tests/autodiff/material/DiffuseMaterial.slang b/tests/autodiff/material/DiffuseMaterial.slang
index e762e17c8..3dd2927f5 100644
--- a/tests/autodiff/material/DiffuseMaterial.slang
+++ b/tests/autodiff/material/DiffuseMaterial.slang
@@ -3,13 +3,13 @@
__exported import IMaterial;
__exported import DiffuseMaterialInstance;
-struct DiffuseMaterial : IMaterial
+public struct DiffuseMaterial : IMaterial
{
- float3 baseColor;
+ public float3 baseColor;
- typedef DiffuseMaterialInstance MaterialInstance;
+ public typedef DiffuseMaterialInstance MaterialInstance;
- DiffuseMaterialInstance setupMaterialInstance()
+ public DiffuseMaterialInstance setupMaterialInstance()
{
DiffuseMaterialInstance mi = { {baseColor} };
return mi;
diff --git a/tests/autodiff/material/DiffuseMaterialInstance.slang b/tests/autodiff/material/DiffuseMaterialInstance.slang
index ca6bfc69a..c6f0e315b 100644
--- a/tests/autodiff/material/DiffuseMaterialInstance.slang
+++ b/tests/autodiff/material/DiffuseMaterialInstance.slang
@@ -3,23 +3,23 @@
__exported import IMaterialInstance;
__exported import IBSDF;
-struct DiffuseBSDF : IBSDF
+public struct DiffuseBSDF : IBSDF
{
- float3 albedo;
+ public float3 albedo;
[TreatAsDifferentiable]
- float3 eval(const float3 wiLocal, const float3 woLocal)
+ public float3 eval(const float3 wiLocal, const float3 woLocal)
{
return albedo;
}
};
-struct DiffuseMaterialInstance : IMaterialInstance
+public struct DiffuseMaterialInstance : IMaterialInstance
{
- DiffuseBSDF bsdf;
+ public DiffuseBSDF bsdf;
[TreatAsDifferentiable]
- float3 eval(const float3 wi, const float3 wo)
+ public float3 eval(const float3 wi, const float3 wo)
{
return bsdf.eval(wi, wo);
}
diff --git a/tests/autodiff/material/GlossyMaterial.slang b/tests/autodiff/material/GlossyMaterial.slang
index 59cee5afe..9848c82ed 100644
--- a/tests/autodiff/material/GlossyMaterial.slang
+++ b/tests/autodiff/material/GlossyMaterial.slang
@@ -3,13 +3,13 @@
__exported import IMaterial;
__exported import GlossyMaterialInstance;
-struct GlossyMaterial : IMaterial
+public struct GlossyMaterial : IMaterial
{
- float3 baseColor;
+ public float3 baseColor;
- typedef GlossyMaterialInstance MaterialInstance;
+ public typedef GlossyMaterialInstance MaterialInstance;
- GlossyMaterialInstance setupMaterialInstance()
+ public GlossyMaterialInstance setupMaterialInstance()
{
GlossyMaterialInstance mi = { { baseColor } };
return mi;
diff --git a/tests/autodiff/material/GlossyMaterialInstance.slang b/tests/autodiff/material/GlossyMaterialInstance.slang
index fbbcc1a26..fb1ce55c0 100644
--- a/tests/autodiff/material/GlossyMaterialInstance.slang
+++ b/tests/autodiff/material/GlossyMaterialInstance.slang
@@ -3,44 +3,44 @@
__exported import IMaterialInstance;
__exported import IBSDF;
-struct GlossyBSDF : IBSDF
+public struct GlossyBSDF : IBSDF
{
- float3 albedo;
+ public float3 albedo;
- float3 getAlbedo()
+ public float3 getAlbedo()
{
return albedo;
}
[ForwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- DifferentialPair<float3> __fwd_d_getAlbedo()
+ public DifferentialPair<float3> __fwd_d_getAlbedo()
{
return diffPair(albedo, float3(1.f));
}
[BackwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- void __bwd_d_getAlbedo(float3 dOut)
+ public void __bwd_d_getAlbedo(float3 dOut)
{
[unroll]
for (int j = 0; j < 3; j++) outputBuffer[j + 3] += dOut[j];
}
[BackwardDifferentiable]
- float3 eval(const float3 wiLocal, const float3 woLocal)
+ public float3 eval(const float3 wiLocal, const float3 woLocal)
{
float3 a = getAlbedo();
return a * a;
}
};
-struct GlossyMaterialInstance : IMaterialInstance
+public struct GlossyMaterialInstance : IMaterialInstance
{
- GlossyBSDF bsdf;
+ public GlossyBSDF bsdf;
[BackwardDifferentiable]
- float3 eval(const float3 wi, const float3 wo)
+ public float3 eval(const float3 wi, const float3 wo)
{
return bsdf.eval(wi, wo);
}
diff --git a/tests/autodiff/material/IBSDF.slang b/tests/autodiff/material/IBSDF.slang
index 9bdeb9197..933392b80 100644
--- a/tests/autodiff/material/IBSDF.slang
+++ b/tests/autodiff/material/IBSDF.slang
@@ -1,9 +1,9 @@
//TEST_IGNORE_FILE:
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=outputBuffer
-RWStructuredBuffer<float> outputBuffer;
+public RWStructuredBuffer<float> outputBuffer;
-interface IBSDF
+public interface IBSDF
{
[BackwardDifferentiable]
float3 eval(const float3 wi, const float3 wo);
diff --git a/tests/autodiff/material/IMaterial.slang b/tests/autodiff/material/IMaterial.slang
index 4bdaac2bc..73390ba0e 100644
--- a/tests/autodiff/material/IMaterial.slang
+++ b/tests/autodiff/material/IMaterial.slang
@@ -2,9 +2,9 @@
__exported import IMaterialInstance;
-interface IMaterial
+public interface IMaterial
{
- associatedtype MaterialInstance : IMaterialInstance;
+ public associatedtype MaterialInstance : IMaterialInstance;
- MaterialInstance setupMaterialInstance();
+ public MaterialInstance setupMaterialInstance();
}
diff --git a/tests/autodiff/material/IMaterialInstance.slang b/tests/autodiff/material/IMaterialInstance.slang
index fb13f8982..4425c2c65 100644
--- a/tests/autodiff/material/IMaterialInstance.slang
+++ b/tests/autodiff/material/IMaterialInstance.slang
@@ -1,7 +1,7 @@
//TEST_IGNORE_FILE:
-interface IMaterialInstance
+public interface IMaterialInstance
{
[BackwardDifferentiable]
- float3 eval(const float3 wi, const float3 wo);
+ public float3 eval(const float3 wi, const float3 wo);
}
diff --git a/tests/autodiff/material/MaterialSystem.slang b/tests/autodiff/material/MaterialSystem.slang
index 5e733fad9..9fcee1386 100644
--- a/tests/autodiff/material/MaterialSystem.slang
+++ b/tests/autodiff/material/MaterialSystem.slang
@@ -2,7 +2,7 @@
__exported import IMaterial;
-IMaterial createMaterialClassConformance(int type, float3 value)
+public IMaterial createMaterialClassConformance(int type, float3 value)
{
return createDynamicObject<IMaterial, float3>(type, value);
}
diff --git a/tests/autodiff/material2/DiffuseMaterial.slang b/tests/autodiff/material2/DiffuseMaterial.slang
index 721445249..d4ae579ff 100644
--- a/tests/autodiff/material2/DiffuseMaterial.slang
+++ b/tests/autodiff/material2/DiffuseMaterial.slang
@@ -3,20 +3,20 @@
__exported import IMaterial;
__exported import DiffuseMaterialInstance;
-struct DiffuseMaterial : IMaterial
+public struct DiffuseMaterial : IMaterial
{
- float3 baseColor;
+ public float3 baseColor;
- typedef DiffuseMaterialInstance MaterialInstance;
+ public typedef DiffuseMaterialInstance MaterialInstance;
[TreatAsDifferentiable]
- float3 getAlbedo(float3 albedo)
+ public float3 getAlbedo(float3 albedo)
{
return albedo;
}
[BackwardDifferentiable]
- DiffuseMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
+ public DiffuseMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
{
float3 albedo = getAlbedo(baseColor);
DiffuseMaterialInstance mi = { baseColor };
diff --git a/tests/autodiff/material2/DiffuseMaterialInstance.slang b/tests/autodiff/material2/DiffuseMaterialInstance.slang
index e33e3f568..7f8421d9f 100644
--- a/tests/autodiff/material2/DiffuseMaterialInstance.slang
+++ b/tests/autodiff/material2/DiffuseMaterialInstance.slang
@@ -3,12 +3,12 @@
__exported import IMaterialInstance;
__exported import IBSDF;
-struct DiffuseMaterialInstance : IMaterialInstance
+public struct DiffuseMaterialInstance : IMaterialInstance
{
- float3 albedo;
+ public float3 albedo;
[BackwardDifferentiable]
- float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
+ public float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
{
float3 albedo;
for (uint i = 0; i < 3; i++) albedo[i] = miData.data[i];
diff --git a/tests/autodiff/material2/GlossyMaterial.slang b/tests/autodiff/material2/GlossyMaterial.slang
index 34ade54cb..e937443d4 100644
--- a/tests/autodiff/material2/GlossyMaterial.slang
+++ b/tests/autodiff/material2/GlossyMaterial.slang
@@ -3,34 +3,34 @@
__exported import IMaterial;
__exported import GlossyMaterialInstance;
-struct GlossyMaterial : IMaterial
+public struct GlossyMaterial : IMaterial
{
- float3 baseColor;
+ public float3 baseColor;
- typedef GlossyMaterialInstance MaterialInstance;
+ public typedef GlossyMaterialInstance MaterialInstance;
- float3 getAlbedo(float3 albedo)
+ public float3 getAlbedo(float3 albedo)
{
return albedo;
}
[ForwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- DifferentialPair<float3> __fwd_d_getAlbedo(DifferentialPair<float3> dpAlbedo)
+ public DifferentialPair<float3> __fwd_d_getAlbedo(DifferentialPair<float3> dpAlbedo)
{
return diffPair(dpAlbedo.p, float3(1.f));
}
[BackwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- void __bwd_d_getAlbedo(inout DifferentialPair<float3> dpAlbedo, float3 dOut)
+ public void __bwd_d_getAlbedo(inout DifferentialPair<float3> dpAlbedo, float3 dOut)
{
[unroll]
for (int j = 0; j < 3; j++) outputBuffer[j + 3] += dOut[j];
}
[BackwardDifferentiable]
- GlossyMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
+ public GlossyMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
{
float3 albedo = getAlbedo(baseColor);
GlossyMaterialInstance mi = { baseColor };
diff --git a/tests/autodiff/material2/GlossyMaterialInstance.slang b/tests/autodiff/material2/GlossyMaterialInstance.slang
index 3cef458ff..64973a5ea 100644
--- a/tests/autodiff/material2/GlossyMaterialInstance.slang
+++ b/tests/autodiff/material2/GlossyMaterialInstance.slang
@@ -3,12 +3,12 @@
__exported import IMaterialInstance;
__exported import IBSDF;
-struct GlossyMaterialInstance : IMaterialInstance
+public struct GlossyMaterialInstance : IMaterialInstance
{
- float3 albedo;
+ public float3 albedo;
[BackwardDifferentiable]
- float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
+ public float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
{
float3 albedo = float3(0.0f, 0.0f, 0.0f);
for (uint i = 0; i < 3; i++) albedo[i] = miData.data[i];
diff --git a/tests/autodiff/material2/IBSDF.slang b/tests/autodiff/material2/IBSDF.slang
index 57cff2883..49bfde6e7 100644
--- a/tests/autodiff/material2/IBSDF.slang
+++ b/tests/autodiff/material2/IBSDF.slang
@@ -1,10 +1,10 @@
//TEST_IGNORE_FILE:
-//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
-RWStructuredBuffer<float> outputBuffer;
+// TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
+public RWStructuredBuffer<float> outputBuffer;
-interface IBSDF
+public interface IBSDF
{
[BackwardDifferentiable]
- float3 eval(const float3 wi, const float3 wo);
+ public float3 eval(const float3 wi, const float3 wo);
}
diff --git a/tests/autodiff/material2/IMaterial.slang b/tests/autodiff/material2/IMaterial.slang
index 66780c9ff..cefb69393 100644
--- a/tests/autodiff/material2/IMaterial.slang
+++ b/tests/autodiff/material2/IMaterial.slang
@@ -2,10 +2,10 @@
__exported import IMaterialInstance;
-interface IMaterial
+public interface IMaterial
{
- associatedtype MaterialInstance : IMaterialInstance;
+ public associatedtype MaterialInstance : IMaterialInstance;
[BackwardDifferentiable]
- MaterialInstance setupMaterialInstance(out MaterialInstanceData miData);
+ public MaterialInstance setupMaterialInstance(out MaterialInstanceData miData);
}
diff --git a/tests/autodiff/material2/IMaterialInstance.slang b/tests/autodiff/material2/IMaterialInstance.slang
index ddf5ca0f6..6b6b617b5 100644
--- a/tests/autodiff/material2/IMaterialInstance.slang
+++ b/tests/autodiff/material2/IMaterialInstance.slang
@@ -1,8 +1,8 @@
//TEST_IGNORE_FILE:
-struct MaterialInstanceData : IDifferentiable
+public struct MaterialInstanceData : IDifferentiable
{
- float data[5];
+ public float data[5];
}
/*
@@ -13,8 +13,8 @@ struct MaterialInstanceSetupResult : IDifferentiable
}
*/
-interface IMaterialInstance
+public interface IMaterialInstance
{
[BackwardDifferentiable]
- float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo);
+ public float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo);
}
diff --git a/tests/autodiff/material2/MaterialSystem.slang b/tests/autodiff/material2/MaterialSystem.slang
index 5e733fad9..9fcee1386 100644
--- a/tests/autodiff/material2/MaterialSystem.slang
+++ b/tests/autodiff/material2/MaterialSystem.slang
@@ -2,7 +2,7 @@
__exported import IMaterial;
-IMaterial createMaterialClassConformance(int type, float3 value)
+public IMaterial createMaterialClassConformance(int type, float3 value)
{
return createDynamicObject<IMaterial, float3>(type, value);
}
diff --git a/tests/autodiff/material2/MxLayeredMaterial.slang b/tests/autodiff/material2/MxLayeredMaterial.slang
index 5e2717b60..8c5cd6d3c 100644
--- a/tests/autodiff/material2/MxLayeredMaterial.slang
+++ b/tests/autodiff/material2/MxLayeredMaterial.slang
@@ -5,54 +5,54 @@ __exported import IMaterialInstance;
import MxLayeredMaterialInstance;
import MxWeights;
-struct LayeredData_mixedLobes : IMxLayeredMaterialData
+public struct LayeredData_mixedLobes : IMxLayeredMaterialData
{
- static const int bsdfCount = 3;
- static const int layerCount = 1;
+ public static const int bsdfCount = 3;
+ public static const int layerCount = 1;
- int getBsdfCount() { return bsdfCount; }
- int getLayerCount() { return layerCount; }
+ public int getBsdfCount() { return bsdfCount; }
+ public int getLayerCount() { return layerCount; }
}
#define TMxLayeredMaterialData LayeredData_mixedLobes
-struct Layered_mixedLobes_WeightsCalculator : IMxLayeredWeightCalculator
+public struct Layered_mixedLobes_WeightsCalculator : IMxLayeredWeightCalculator
{
- void calculateWeights<let TBsdfCount : int, let TLayerCount : int, TLayeredMaterialData : IMxLayeredMaterialData>(
+ public void calculateWeights<let TBsdfCount : int, let TLayerCount : int, TLayeredMaterialData : IMxLayeredMaterialData>(
const TLayeredMaterialData data, out MxWeights<TBsdfCount> weights)
{
for (uint i = 0; i < TBsdfCount; i++) weights.weights[i] = float3(0.f);
}
}
-struct MxLayeredMaterial : IMaterial
+public struct MxLayeredMaterial : IMaterial
{
- float3 baseColor;
+ public float3 baseColor;
- typealias UsedMaterialInstance = MxLayeredMaterialInstance<3, 1, TMxLayeredMaterialData, Layered_mixedLobes_WeightsCalculator>;
- typedef UsedMaterialInstance MaterialInstance;
+ public typealias UsedMaterialInstance = MxLayeredMaterialInstance<3, 1, TMxLayeredMaterialData, Layered_mixedLobes_WeightsCalculator>;
+ public typedef UsedMaterialInstance MaterialInstance;
- float3 getAlbedo(float3 albedo)
+ public float3 getAlbedo(float3 albedo)
{
return albedo;
}
[ForwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- DifferentialPair<float3> __fwd_d_getAlbedo(DifferentialPair<float3> dpAlbedo)
+ public DifferentialPair<float3> __fwd_d_getAlbedo(DifferentialPair<float3> dpAlbedo)
{
return diffPair(dpAlbedo.p, float3(1.f));
}
[BackwardDerivativeOf(getAlbedo)]
[TreatAsDifferentiable]
- void __bwd_d_getAlbedo(inout DifferentialPair<float3> dpAlbedo, float3 dOut)
+ public void __bwd_d_getAlbedo(inout DifferentialPair<float3> dpAlbedo, float3 dOut)
{
[unroll]
for (int j = 0; j < 3; j++) outputBuffer[j + 6] += dOut[j];
}
-
+
[Differentiable]
- UsedMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
+ public UsedMaterialInstance setupMaterialInstance(out MaterialInstanceData miData)
{
float3 albedo = getAlbedo(baseColor);
UsedMaterialInstance mi;
diff --git a/tests/autodiff/material2/MxLayeredMaterialInstance.slang b/tests/autodiff/material2/MxLayeredMaterialInstance.slang
index 53a319d6f..ed2ef1cb0 100644
--- a/tests/autodiff/material2/MxLayeredMaterialInstance.slang
+++ b/tests/autodiff/material2/MxLayeredMaterialInstance.slang
@@ -5,17 +5,17 @@ __exported import IBSDF;
import MxWeights;
-struct MxLayeredMaterialInstance<
+public struct MxLayeredMaterialInstance<
let TBsdfCount : int,
let TLayerCount : int,
TLayeredMaterialData : IMxLayeredMaterialData,
TWeightsCalc : IMxLayeredWeightCalculator> : IMaterialInstance
{
- TLayeredMaterialData data;
- TWeightsCalc calculator;
- typealias Weights = MxWeights<TBsdfCount>;
+ public TLayeredMaterialData data;
+ public TWeightsCalc calculator;
+ public typealias Weights = MxWeights<TBsdfCount>;
- Weights calculateWeights()
+ public Weights calculateWeights()
{
Weights result;
calculator.calculateWeights<TBsdfCount, TLayerCount, TLayeredMaterialData>(data, result);
@@ -23,7 +23,7 @@ struct MxLayeredMaterialInstance<
}
[Differentiable]
- float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
+ public float3 eval(const MaterialInstanceData miData, const float3 wi, const float3 wo)
{
float3 albedo;
for (uint i = 0; i < 3; i++) albedo[i] = miData.data[i];
diff --git a/tests/autodiff/material2/MxWeights.slang b/tests/autodiff/material2/MxWeights.slang
index 1d1a9f543..1e9c7d36c 100644
--- a/tests/autodiff/material2/MxWeights.slang
+++ b/tests/autodiff/material2/MxWeights.slang
@@ -1,18 +1,18 @@
//TEST_IGNORE_FILE:
-struct MxWeights<let TBsdfCount : int>
+public struct MxWeights<let TBsdfCount : int>
{
- float3 weights[TBsdfCount];
+ public float3 weights[TBsdfCount];
}
-interface IMxLayeredMaterialData
+public interface IMxLayeredMaterialData
{
- int getBsdfCount();
- int getLayerCount();
+ public int getBsdfCount();
+ public int getLayerCount();
}
-interface IMxLayeredWeightCalculator
+public interface IMxLayeredWeightCalculator
{
- void calculateWeights<let TBsdfCount : int, let TLayerCount: int, TLayeredMaterialData : IMxLayeredMaterialData>(
+ public void calculateWeights<let TBsdfCount : int, let TLayerCount: int, TLayeredMaterialData : IMxLayeredMaterialData>(
const TLayeredMaterialData data, out MxWeights<TBsdfCount> weights);
}
diff --git a/tests/bindings/multi-file-defines.h b/tests/bindings/multi-file-defines.h
index 52a5826b6..db0261158 100644
--- a/tests/bindings/multi-file-defines.h
+++ b/tests/bindings/multi-file-defines.h
@@ -5,12 +5,13 @@
#define BEGIN_CBUFFER(NAME) cbuffer NAME
#define END_CBUFFER(NAME, REG) /**/
#define CBUFFER_REF(NAME, FIELD) FIELD
+#define PUBLIC public
#else
#define R(X) X
#define BEGIN_CBUFFER(NAME) struct SLANG_ParameterGroup_##NAME
#define END_CBUFFER(NAME, REG) ; cbuffer NAME : REG { SLANG_ParameterGroup_##NAME NAME; }
#define CBUFFER_REF(NAME, FIELD) NAME.FIELD
-
+#define PUBLIC
#define sharedC sharedC_0
#define sharedCA sharedCA_0
#define sharedCB sharedCB_0
diff --git a/tests/bindings/multi-file-shared.slang b/tests/bindings/multi-file-shared.slang
index af91d5251..dcfa6251c 100644
--- a/tests/bindings/multi-file-shared.slang
+++ b/tests/bindings/multi-file-shared.slang
@@ -3,23 +3,23 @@
#include "multi-file-defines.h"
-float4 use(float val) { return val; };
-float4 use(float2 val) { return float4(val,0.0,0.0); };
-float4 use(float3 val) { return float4(val,0.0); };
-float4 use(float4 val) { return val; };
-float4 use(Texture2D t, SamplerState s) { return t.SampleLevel(s, 0.0, 0.0); }
+PUBLIC float4 use(float val) { return val; };
+PUBLIC float4 use(float2 val) { return float4(val,0.0,0.0); };
+PUBLIC float4 use(float3 val) { return float4(val,0.0); };
+PUBLIC float4 use(float4 val) { return val; };
+PUBLIC float4 use(Texture2D t, SamplerState s) { return t.SampleLevel(s, 0.0, 0.0); }
-Texture2D sharedT R(: register(t2));
-SamplerState sharedS R(: register(s2));
+PUBLIC Texture2D sharedT R(: register(t2));
+PUBLIC SamplerState sharedS R(: register(s2));
-BEGIN_CBUFFER(sharedC)
+PUBLIC BEGIN_CBUFFER(sharedC)
{
- float3 sharedCA;
- float sharedCB;
- float3 sharedCC;
- float2 sharedCD;
+ PUBLIC float3 sharedCA;
+ PUBLIC float sharedCB;
+ PUBLIC float3 sharedCC;
+ PUBLIC float2 sharedCD;
}
END_CBUFFER(sharedC, register(b2))
-Texture2D sharedTV R(: register(t3));
-Texture2D sharedTF R(: register(t4));
+PUBLIC Texture2D sharedTV R(: register(t3));
+PUBLIC Texture2D sharedTF R(: register(t4));
diff --git a/tests/bugs/gl-33-ext.slang b/tests/bugs/gl-33-ext.slang
index ae70cfaf0..fccde99a3 100644
--- a/tests/bugs/gl-33-ext.slang
+++ b/tests/bugs/gl-33-ext.slang
@@ -1,8 +1,8 @@
// gl-33-ext.slang
//TEST_IGNORE_FILE:
-struct A
+public struct A
{
- int state;
- [mutating] int next() { return state; }
+ public int state;
+ [mutating] public int next() { return state; }
};
diff --git a/tests/bugs/interface-lvalue.slang b/tests/bugs/interface-lvalue.slang
index 87cfa54ed..e80a130d1 100644
--- a/tests/bugs/interface-lvalue.slang
+++ b/tests/bugs/interface-lvalue.slang
@@ -23,7 +23,7 @@ void createFoo(out IFoo val)
val = resuult;
}
-public __extern_cpp int main()
+export __extern_cpp int main()
{
IFoo v;
createFoo(v);
diff --git a/tests/bugs/split-nested-types.slang b/tests/bugs/split-nested-types.slang
index 3bd4e239f..b9bfb9e62 100644
--- a/tests/bugs/split-nested-types.slang
+++ b/tests/bugs/split-nested-types.slang
@@ -1,14 +1,14 @@
//TEST_IGNORE_FILE:
-struct A { int x; };
+public struct A { public int x; };
-struct B { float y; };
+public struct B { public float y; };
-struct CC { Texture2D t; SamplerState s; };
+public struct CC { public Texture2D t; public SamplerState s; };
-struct M
+public struct M
{
- A a;
- B b;
- CC c;
+ public A a;
+ public B b;
+ public CC c;
};
diff --git a/tests/compute/array-existential-parameter.slang b/tests/compute/array-existential-parameter.slang
index 813c5a40b..b7473e447 100644
--- a/tests/compute/array-existential-parameter.slang
+++ b/tests/compute/array-existential-parameter.slang
@@ -38,7 +38,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
//TEST_INPUT: globalExistentialType __Dynamic
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
int val;
int run(int input)
diff --git a/tests/compute/dynamic-dispatch-11.slang b/tests/compute/dynamic-dispatch-11.slang
index d6f64aa99..59e7ce581 100644
--- a/tests/compute/dynamic-dispatch-11.slang
+++ b/tests/compute/dynamic-dispatch-11.slang
@@ -34,7 +34,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
// No type input for dynamic dispatch //TEST_INPUT: globalExistentialType MyImpl
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
int val;
int run(int input)
diff --git a/tests/compute/dynamic-dispatch-12.slang b/tests/compute/dynamic-dispatch-12.slang
index 906a5da0e..28f9c4c14 100644
--- a/tests/compute/dynamic-dispatch-12.slang
+++ b/tests/compute/dynamic-dispatch-12.slang
@@ -37,14 +37,14 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
}
// Specialize gCb1, but not gCb2
-//TEST_INPUT: globalExistentialType MyImpl
-//TEST_INPUT: globalExistentialType __Dynamic
+// TEST_INPUT: globalExistentialType MyImpl
+// TEST_INPUT: globalExistentialType __Dynamic
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
int val;
int run(int input)
{
return input + val;
}
-}; \ No newline at end of file
+};
diff --git a/tests/compute/dynamic-dispatch-13.slang b/tests/compute/dynamic-dispatch-13.slang
index f9ad9683b..20d78e0ad 100644
--- a/tests/compute/dynamic-dispatch-13.slang
+++ b/tests/compute/dynamic-dispatch-13.slang
@@ -35,7 +35,7 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
}
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
int val;
int run(int input)
@@ -43,7 +43,7 @@ public struct MyImpl : IInterface
return input + val;
}
};
-public struct MyImpl2 : IInterface
+export struct MyImpl2 : IInterface
{
int val;
int run(int input)
diff --git a/tests/compute/dynamic-dispatch-14.slang b/tests/compute/dynamic-dispatch-14.slang
index e605132c6..0dc99b432 100644
--- a/tests/compute/dynamic-dispatch-14.slang
+++ b/tests/compute/dynamic-dispatch-14.slang
@@ -46,10 +46,10 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
}
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
int val;
- public struct TAssoc : IAssoc
+ export struct TAssoc : IAssoc
{
int val;
int eval() { return val; }
@@ -62,10 +62,10 @@ public struct MyImpl : IInterface
}
};
-public struct MyImpl2 : IInterface
+export struct MyImpl2 : IInterface
{
int val;
- public struct TAssoc : IAssoc
+ export struct TAssoc : IAssoc
{
int val;
int eval() { return val; }
@@ -76,4 +76,4 @@ public struct MyImpl2 : IInterface
rs.val = input - val;
return rs;
}
-}; \ No newline at end of file
+};
diff --git a/tests/compute/dynamic-dispatch-15.slang b/tests/compute/dynamic-dispatch-15.slang
index 5e2be1a4c..2ab169281 100644
--- a/tests/compute/dynamic-dispatch-15.slang
+++ b/tests/compute/dynamic-dispatch-15.slang
@@ -46,7 +46,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
}
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct FloatVal : IInterface
+export struct FloatVal : IInterface
{
float val;
float run()
@@ -56,7 +56,7 @@ public struct FloatVal : IInterface
};
interface ISomething{void g();}
struct Float4Struct : ISomething { float4 val; void g() {} }
-public struct Float4Val : IInterface
+export struct Float4Val : IInterface
{
Float4Struct val;
float run()
@@ -64,7 +64,7 @@ public struct Float4Val : IInterface
return val.val.x;
}
};
-public struct IntVal : IInterface
+export struct IntVal : IInterface
{
int val;
float run()
@@ -72,11 +72,11 @@ public struct IntVal : IInterface
return val;
}
};
-public struct Int4Val : IInterface
+export struct Int4Val : IInterface
{
int4 val;
float run()
{
return val.x;
}
-}; \ No newline at end of file
+};
diff --git a/tests/compute/dynamic-dispatch-bindless-texture.slang b/tests/compute/dynamic-dispatch-bindless-texture.slang
index 04c1f1766..34ef67d1e 100644
--- a/tests/compute/dynamic-dispatch-bindless-texture.slang
+++ b/tests/compute/dynamic-dispatch-bindless-texture.slang
@@ -28,7 +28,7 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
//TEST_INPUT: globalExistentialType __Dynamic
// Type must be marked `public` to ensure it is visible in the generated DLL.
-public struct MyImpl : IInterface
+export struct MyImpl : IInterface
{
Texture2D tex;
SamplerState sampler;
diff --git a/tests/compute/interface-assoc-type-param.slang b/tests/compute/interface-assoc-type-param.slang
index 805f673a2..a234d457f 100644
--- a/tests/compute/interface-assoc-type-param.slang
+++ b/tests/compute/interface-assoc-type-param.slang
@@ -16,7 +16,7 @@ interface IEval
uint eval();
}
-public struct Impl : IInterface
+export struct Impl : IInterface
{
uint val;
struct TEval : IEval
@@ -55,4 +55,4 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
{
uint tid = dispatchThreadID.x;
compute(tid, params);
-} \ No newline at end of file
+}
diff --git a/tests/compute/interface-func-param-in-struct.slang b/tests/compute/interface-func-param-in-struct.slang
index c47b25d70..01e4aa111 100644
--- a/tests/compute/interface-func-param-in-struct.slang
+++ b/tests/compute/interface-func-param-in-struct.slang
@@ -9,7 +9,7 @@ interface IInterface
uint eval();
}
-public struct Impl : IInterface
+export struct Impl : IInterface
{
uint val;
uint eval()
@@ -38,4 +38,4 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
{
uint tid = dispatchThreadID.x;
compute(tid, params);
-} \ No newline at end of file
+}
diff --git a/tests/compute/interface-param-partial-specialize.slang b/tests/compute/interface-param-partial-specialize.slang
index 9be22c6c4..1d09c9f55 100644
--- a/tests/compute/interface-param-partial-specialize.slang
+++ b/tests/compute/interface-param-partial-specialize.slang
@@ -12,7 +12,7 @@ interface IInterface
uint eval();
}
-public struct Impl : IInterface
+export struct Impl : IInterface
{
uint val;
uint eval()
@@ -48,4 +48,4 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
{
uint tid = dispatchThreadID.x;
compute(tid, params);
-} \ No newline at end of file
+}
diff --git a/tests/cpu-program/class-com.slang b/tests/cpu-program/class-com.slang
index e2812f586..2dd84d696 100644
--- a/tests/cpu-program/class-com.slang
+++ b/tests/cpu-program/class-com.slang
@@ -20,7 +20,7 @@ class MyClass : IFoo
};
[DllExport]
-IFoo createFoo()
+export IFoo createFoo()
{
IFoo result = new MyClass();
return result;
@@ -30,8 +30,8 @@ IFoo createFoo()
[DllImport("", "createFoo")]
IFoo createFooImported();
-public __extern_cpp int main()
+export __extern_cpp int main()
{
var obj = createFooImported();
return obj.method();
-} \ No newline at end of file
+}
diff --git a/tests/cpu-program/class.slang b/tests/cpu-program/class.slang
index 1a510118a..8935b157a 100644
--- a/tests/cpu-program/class.slang
+++ b/tests/cpu-program/class.slang
@@ -13,8 +13,8 @@ class MyClass
}
}
-public __extern_cpp int main()
+export __extern_cpp int main()
{
MyClass obj = new MyClass();
return obj.method();
-} \ No newline at end of file
+}
diff --git a/tests/cpu-program/cpu-hello-world.slang b/tests/cpu-program/cpu-hello-world.slang
index f1285f889..a44761e8f 100644
--- a/tests/cpu-program/cpu-hello-world.slang
+++ b/tests/cpu-program/cpu-hello-world.slang
@@ -1,6 +1,6 @@
//TEST:EXECUTABLE:
-public __extern_cpp int main()
+export __extern_cpp int main()
{
printf("Hello World.\n");
return 0;
diff --git a/tests/cpu-program/gfx-smoke.slang b/tests/cpu-program/gfx-smoke.slang
index d0acb83db..41c87ca19 100644
--- a/tests/cpu-program/gfx-smoke.slang
+++ b/tests/cpu-program/gfx-smoke.slang
@@ -2,7 +2,7 @@
import gfx;
import slang;
-public __extern_cpp int main()
+export __extern_cpp int main()
{
gfx.DeviceDesc deviceDesc = {};
deviceDesc.deviceType = gfx.DeviceType.CPU;
@@ -98,4 +98,4 @@ public __extern_cpp int main()
printf("%.1f\n", val);
}
return 0;
-} \ No newline at end of file
+}
diff --git a/tests/cpu-program/pointer-basics.slang b/tests/cpu-program/pointer-basics.slang
index e38d866eb..db705d507 100644
--- a/tests/cpu-program/pointer-basics.slang
+++ b/tests/cpu-program/pointer-basics.slang
@@ -1,5 +1,5 @@
//TEST:EXECUTABLE:
-public __extern_cpp int main()
+export __extern_cpp int main()
{
uint2 value;
int *pValue = (int*)&value;
@@ -20,4 +20,4 @@ public __extern_cpp int main()
else
printf("Fail\n");
return 0;
-} \ No newline at end of file
+}
diff --git a/tests/cpu-program/pointer-deref.slang b/tests/cpu-program/pointer-deref.slang
index 79f1b2cd0..f5bad5b09 100644
--- a/tests/cpu-program/pointer-deref.slang
+++ b/tests/cpu-program/pointer-deref.slang
@@ -11,7 +11,7 @@ struct Record
SubRecord sub;
}
-public __extern_cpp int main()
+export __extern_cpp int main()
{
Record rec;
Record *pRec = &rec;
@@ -27,4 +27,4 @@ public __extern_cpp int main()
printf("fail\n");
}
return 0;
-} \ No newline at end of file
+}
diff --git a/tests/current-bugs/resource-dynamic-dispatch.slang b/tests/current-bugs/resource-dynamic-dispatch.slang
index 0a987b1cf..f344448dd 100644
--- a/tests/current-bugs/resource-dynamic-dispatch.slang
+++ b/tests/current-bugs/resource-dynamic-dispatch.slang
@@ -26,13 +26,13 @@ interface IInterface
};
// Need public to make these conformances available
-public struct A : IInterface
+export struct A : IInterface
{
typedef SomeData Type;
IGetTexture getType() { Type t = { gTexA }; return t; }
};
-public struct B : IInterface
+export struct B : IInterface
{
typedef SomeData Type;
IGetTexture getType() { Type t = { gTexB }; return t; }
@@ -64,4 +64,4 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
let tex = getTex.getTexture();
outputBuffer[tid] = tex.Load(int3(tid, tid, 0));
-} \ No newline at end of file
+}
diff --git a/tests/diagnostics/extension-visibility-a.slang b/tests/diagnostics/extension-visibility-a.slang
index 97e4ef85c..162320d51 100644
--- a/tests/diagnostics/extension-visibility-a.slang
+++ b/tests/diagnostics/extension-visibility-a.slang
@@ -1,17 +1,17 @@
// extension-visibility-a.slang
-interface IThing
+public interface IThing
{
- int getValue();
+ public int getValue();
}
// Note: not implementing the interface here!
-struct MyThing
+public struct MyThing
{
- int value;
+ public int value;
}
-int helper<T : IThing>(T thing)
+public int helper<T : IThing>(T thing)
{
return thing.getValue();
-} \ No newline at end of file
+}
diff --git a/tests/diagnostics/extension-visibility-b.slang b/tests/diagnostics/extension-visibility-b.slang
index 7848f2a56..dbefe66e7 100644
--- a/tests/diagnostics/extension-visibility-b.slang
+++ b/tests/diagnostics/extension-visibility-b.slang
@@ -2,7 +2,7 @@
import extension_visibility_a;
-extension MyThing : IThing
+public extension MyThing : IThing
{
- int getValue() { return value; }
+ public int getValue() { return value; }
}
diff --git a/tests/diagnostics/extension-visibility-c.slang b/tests/diagnostics/extension-visibility-c.slang
index 2d7a5224d..71680b31e 100644
--- a/tests/diagnostics/extension-visibility-c.slang
+++ b/tests/diagnostics/extension-visibility-c.slang
@@ -3,7 +3,7 @@
import extension_visibility_a;
import extension_visibility_b;
-int works(MyThing thing)
+public int works(MyThing thing)
{
return helper(thing);
}
diff --git a/tests/diagnostics/extension-visibility.slang.expected b/tests/diagnostics/extension-visibility.slang.expected
index 732ff4189..eed86715d 100644
--- a/tests/diagnostics/extension-visibility.slang.expected
+++ b/tests/diagnostics/extension-visibility.slang.expected
@@ -3,9 +3,9 @@ standard error = {
tests/diagnostics/extension-visibility.slang(17): error 39999: could not specialize generic for arguments of type (MyThing)
return helper(thing);
^
-tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of func helper<T>(T) -> int
-int helper<T : IThing>(T thing)
- ^~~~~~
+tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of public func helper<T>(T) -> int
+public int helper<T : IThing>(T thing)
+ ^~~~~~
}
standard output = {
}
diff --git a/tests/diagnostics/internal-visibility/that-module-impl.slang b/tests/diagnostics/internal-visibility/that-module-impl.slang
new file mode 100644
index 000000000..893510afe
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/that-module-impl.slang
@@ -0,0 +1,17 @@
+implementing "that-module";
+
+
+public void publicFunc2() { }
+
+internal void internalFunc1() {}
+
+public struct PublicStruct
+{
+ int x;
+ public int y;
+}
+
+public namespace Namespace
+{
+ public static int publicVar2;
+}
diff --git a/tests/diagnostics/internal-visibility/that-module.slang b/tests/diagnostics/internal-visibility/that-module.slang
new file mode 100644
index 000000000..b072c7231
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/that-module.slang
@@ -0,0 +1,25 @@
+module "that-module";
+
+__include "that-module-impl";
+
+void internalMethod();
+
+public void publicMethod();
+
+public namespace Namespace
+{
+ static int internalVar;
+
+ public static int publicVar;
+}
+
+enum InternalEnum
+{
+ A,B,C
+}
+public enum PublicEnum
+{
+ D,E,F
+}
+
+struct InternalStruct { int x; }
diff --git a/tests/diagnostics/internal-visibility/this-module.slang b/tests/diagnostics/internal-visibility/this-module.slang
new file mode 100644
index 000000000..98e0f3d08
--- /dev/null
+++ b/tests/diagnostics/internal-visibility/this-module.slang
@@ -0,0 +1,26 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+module "this-module";
+
+import "that-module";
+
+void test()
+{
+ PublicStruct s;
+ // CHECK:{{.*}}(11): error 30600:
+ s.x = 1; // Error.
+ // CHECK-NOT:{{.*}}error
+ s.y = 2; // OK.
+ publicMethod(); // OK.
+ publicFunc2(); // OK.
+ Namespace.publicVar = 1; // OK.
+ Namespace.publicVar2 = 1; // OK.
+ // CHECK:{{.*}}(19): error 30600:
+ Namespace.internalVar = 1; // error.
+ // CHECK:{{.*}}(21): error 30600:
+ InternalEnum e; // Error.
+ // CHECK:{{.*}}(23): error 30600:
+ InternalStruct s1; // Error.
+ // CHECK:{{.*}}(25): error 30600:
+ internalMethod(); // Error.
+}
diff --git a/tests/diagnostics/private-visibility.slang b/tests/diagnostics/private-visibility.slang
new file mode 100644
index 000000000..7c0bad970
--- /dev/null
+++ b/tests/diagnostics/private-visibility.slang
@@ -0,0 +1,44 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+struct MyType
+{
+ private int member;
+ private int func()
+ {
+ return member;
+ }
+ struct SubType
+ {
+ int member2;
+ int func2(MyType m)
+ {
+ return m.member + member2; // OK.
+ }
+ }
+ int func1() { return member; }
+
+ private __init() { member = 0; }
+
+ private __subscript(int i)->int
+ {
+ get { return member; }
+ set { member = newValue; }
+ }
+ // CHECK:{{.*}}(28): error 30601:
+ public void publicMethod() {} // ERROR.
+}
+
+void test()
+{
+ // CHECK:{{.*}}(34): error 30600:
+ MyType t; // ERROR.
+ // CHECK-NOT:{{.*}}error
+ t.func1(); // OK.
+ // CHECK:{{.*}}(38): error 30600:
+ t.func(); // ERROR.
+ // CHECK:{{.*}}(40): error 30600:
+ t[0] = 1; // ERROR.
+
+ // CHECK:{{.*}}(43): error 30600:
+ t.member = 2;
+}
diff --git a/tests/diagnostics/visibility.slang b/tests/diagnostics/visibility.slang
new file mode 100644
index 000000000..724ec30e7
--- /dev/null
+++ b/tests/diagnostics/visibility.slang
@@ -0,0 +1,23 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+// CHECK-DAG:{{.*}}(4): error 30603
+private struct MyStruct
+{}
+
+struct IS
+{
+ // CHECK-DAG:{{.*}}(10): error 30601
+ public void fp();
+}
+
+// CHECK-DAG:{{.*}}(14): error 30604
+public IS f() {}
+
+public struct PS
+{
+ // CHECK-DAG:{{.*}}(19): error 30604
+ public IS ii;
+
+ // CHECK-DAG:{{.*}}(22): error 30604
+ public property IS ii2 { get { return {}; } };
+}
diff --git a/tests/front-end/import-exported-b.slang b/tests/front-end/import-exported-b.slang
index 144f62060..e7bc49510 100644
--- a/tests/front-end/import-exported-b.slang
+++ b/tests/front-end/import-exported-b.slang
@@ -2,4 +2,4 @@
// This file defines the code that will be (transitively) imported into `import-exported.slang`
-float foo(float x) { return x; } \ No newline at end of file
+public float foo(float x) { return x; }
diff --git a/tests/front-end/import-subdir-search-path.slang b/tests/front-end/import-subdir-search-path.slang
index 9b7c7a520..b35802f14 100644
--- a/tests/front-end/import-subdir-search-path.slang
+++ b/tests/front-end/import-subdir-search-path.slang
@@ -7,4 +7,4 @@ __import import_subdir_a;
// Should realize it's the same thing
__import subdir.import_subdir_a;
-float bar(float x) { return foo(x); } \ No newline at end of file
+float bar(float x) { return foo(x); }
diff --git a/tests/front-end/raw-string-literal.slang b/tests/front-end/raw-string-literal.slang
index 321f183c7..7297c27e1 100644
--- a/tests/front-end/raw-string-literal.slang
+++ b/tests/front-end/raw-string-literal.slang
@@ -17,7 +17,7 @@ void printLines(NativeString text)
}
}
-public __extern_cpp int main()
+export __extern_cpp int main()
{
printLines(
R"(This is line 1.
@@ -25,4 +25,4 @@ public __extern_cpp int main()
"Hello World"
)");
return 0;
-} \ No newline at end of file
+}
diff --git a/tests/front-end/subdir/import-subdir-a.slang b/tests/front-end/subdir/import-subdir-a.slang
index 3962d4662..e973d5cbf 100644
--- a/tests/front-end/subdir/import-subdir-a.slang
+++ b/tests/front-end/subdir/import-subdir-a.slang
@@ -2,4 +2,4 @@
// This is the imported code.
-float foo(float x) { return x; } \ No newline at end of file
+public float foo(float x) { return x; }
diff --git a/tests/ir/string-literal-module.slang b/tests/ir/string-literal-module.slang
index 96fb62088..245b4b3a2 100644
--- a/tests/ir/string-literal-module.slang
+++ b/tests/ir/string-literal-module.slang
@@ -1,6 +1,6 @@
//TEST_IGNORE_FILE:
-int doSomethingElse()
+public int doSomethingElse()
{
return getStringHash("Try another");
}
diff --git a/tests/language-feature/extensions/extension-import-helper.slang b/tests/language-feature/extensions/extension-import-helper.slang
index c1a652645..11265762a 100644
--- a/tests/language-feature/extensions/extension-import-helper.slang
+++ b/tests/language-feature/extensions/extension-import-helper.slang
@@ -2,12 +2,12 @@
//TEST_IGNORE_FILE:
-interface IThing
+public interface IThing
{
- float getValue();
+ public float getValue();
}
-extension float : IThing
+public extension float : IThing
{
- float getValue() { return this; }
-} \ No newline at end of file
+ public float getValue() { return this; }
+}
diff --git a/tests/language-feature/generics/struct-generic-value-param-import.slang b/tests/language-feature/generics/struct-generic-value-param-import.slang
index edc1b0c39..785b8146f 100644
--- a/tests/language-feature/generics/struct-generic-value-param-import.slang
+++ b/tests/language-feature/generics/struct-generic-value-param-import.slang
@@ -6,13 +6,13 @@
// for `struct` decalrations in Slang files, including
// any `import`ed code.
-interface IData {}
+public interface IData {}
-struct Data<let kCount : int> : IData
+public struct Data<let kCount : int> : IData
{
- int state;
+ public int state;
- [mutating] void doStuff()
+ [mutating] public void doStuff()
{
state++;
}
diff --git a/tests/language-feature/inheritance/struct-inheritance-imported.slang b/tests/language-feature/inheritance/struct-inheritance-imported.slang
index 8786b851c..16816ec97 100644
--- a/tests/language-feature/inheritance/struct-inheritance-imported.slang
+++ b/tests/language-feature/inheritance/struct-inheritance-imported.slang
@@ -1,12 +1,12 @@
//TEST_IGNORE_FILE:
// struct-inheritance-imported.slang
-struct Base
+public struct Base
{
- int a;
+ public int a;
}
-struct Derived : Base
+public struct Derived : Base
{}
-int getA(Derived d) { return d.a; }
+public int getA(Derived d) { return d.a; }
diff --git a/tests/library/library.slang b/tests/library/library.slang
index fafb1018c..3deaeab99 100644
--- a/tests/library/library.slang
+++ b/tests/library/library.slang
@@ -2,12 +2,12 @@
// library.slang
-int doThing(int b)
+export int doThing(int b)
{
return b + b + 1;
}
-public int foo(int a)
+public export int foo(int a)
{
return a * a + 1 + doThing(a + 2);
}
diff --git a/tests/reflection/multi-file-defines.h b/tests/reflection/multi-file-defines.h
index aed4c510a..0948df378 100644
--- a/tests/reflection/multi-file-defines.h
+++ b/tests/reflection/multi-file-defines.h
@@ -5,12 +5,13 @@
#define BEGIN_CBUFFER(NAME) cbuffer NAME
#define END_CBUFFER(NAME, REG) /**/
#define CBUFFER_REF(NAME, FIELD) FIELD
+#define PUBLIC public
#else
#define R(X) /*X*/
#define BEGIN_CBUFFER(NAME) struct SLANG_ParameterGroup_##NAME
#define END_CBUFFER(NAME, REG) ; cbuffer NAME /*REG*/ { SLANG_ParameterGroup_##NAME NAME; }
#define CBUFFER_REF(NAME, FIELD) NAME.FIELD
-
+#define PUBLIC
#define sharedC sharedC_0
#define sharedCA sharedCA_0
#define sharedCB sharedCB_0
diff --git a/tests/reflection/multi-file-shared.slang b/tests/reflection/multi-file-shared.slang
index af91d5251..91a74cd35 100644
--- a/tests/reflection/multi-file-shared.slang
+++ b/tests/reflection/multi-file-shared.slang
@@ -3,23 +3,23 @@
#include "multi-file-defines.h"
-float4 use(float val) { return val; };
-float4 use(float2 val) { return float4(val,0.0,0.0); };
-float4 use(float3 val) { return float4(val,0.0); };
-float4 use(float4 val) { return val; };
-float4 use(Texture2D t, SamplerState s) { return t.SampleLevel(s, 0.0, 0.0); }
+PUBLIC float4 use(float val) { return val; };
+PUBLIC float4 use(float2 val) { return float4(val,0.0,0.0); };
+PUBLIC float4 use(float3 val) { return float4(val,0.0); };
+PUBLIC float4 use(float4 val) { return val; };
+PUBLIC float4 use(Texture2D t, SamplerState s) { return t.SampleLevel(s, 0.0, 0.0); }
-Texture2D sharedT R(: register(t2));
-SamplerState sharedS R(: register(s2));
+PUBLIC Texture2D sharedT R(: register(t2));
+PUBLIC SamplerState sharedS R(: register(s2));
-BEGIN_CBUFFER(sharedC)
+PUBLIC BEGIN_CBUFFER(sharedC)
{
- float3 sharedCA;
- float sharedCB;
- float3 sharedCC;
- float2 sharedCD;
+ PUBLIC float3 sharedCA;
+ PUBLIC float sharedCB;
+ PUBLIC float3 sharedCC;
+ PUBLIC float2 sharedCD;
}
END_CBUFFER(sharedC, register(b2))
-Texture2D sharedTV R(: register(t3));
-Texture2D sharedTF R(: register(t4));
+PUBLIC Texture2D sharedTV R(: register(t3));
+PUBLIC Texture2D sharedTF R(: register(t4));
diff --git a/tests/reflection/reflect-imported-code.slang b/tests/reflection/reflect-imported-code.slang
index 20beb94b8..4600a371c 100644
--- a/tests/reflection/reflect-imported-code.slang
+++ b/tests/reflection/reflect-imported-code.slang
@@ -2,13 +2,13 @@
// Imported code used by `reflect-imported-code.hlsl`
-float4 use(float4 val) { return val; };
-float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
+public float4 use(float4 val) { return val; };
+public float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
-Texture2D t_i;
-SamplerState s_i;
+public Texture2D t_i;
+public SamplerState s_i;
-cbuffer C_i
+public cbuffer C_i
{
- float c_i;
+ public float c_i;
}
diff --git a/tests/vkray/callable-shared.slang b/tests/vkray/callable-shared.slang
index 09e76aab1..85d72a5f7 100644
--- a/tests/vkray/callable-shared.slang
+++ b/tests/vkray/callable-shared.slang
@@ -1,8 +1,8 @@
// callable-shared.slang
//TEST_IGNORE_FILE:
-struct MaterialPayload
+public struct MaterialPayload
{
- float4 albedo;
- float2 uv;
+ public float4 albedo;
+ public float2 uv;
};
diff --git a/tools/gfx-unit-test/shader-cache-tests.cpp b/tools/gfx-unit-test/shader-cache-tests.cpp
index 3879fd630..4477c4f56 100644
--- a/tools/gfx-unit-test/shader-cache-tests.cpp
+++ b/tools/gfx-unit-test/shader-cache-tests.cpp
@@ -430,7 +430,7 @@ namespace gfx_test
{
String importedContentsA = String(
R"(
- void processElement(RWStructuredBuffer<float> buffer, uint index)
+ public void processElement(RWStructuredBuffer<float> buffer, uint index)
{
var input = buffer[index];
buffer[index] = input + 1.0f;
@@ -439,7 +439,7 @@ namespace gfx_test
String importedContentsB = String(
R"(
- void processElement(RWStructuredBuffer<float> buffer, uint index)
+ public void processElement(RWStructuredBuffer<float> buffer, uint index)
{
var input = buffer[index];
buffer[index] = input + 2.0f;
diff --git a/tools/gfx/gfx.slang b/tools/gfx/gfx.slang
index e8750ada7..e9a31445b 100644
--- a/tools/gfx/gfx.slang
+++ b/tools/gfx/gfx.slang
@@ -1,25 +1,25 @@
import slang;
-namespace gfx
+public namespace gfx
{
-typedef slang.Result Result;
+public typedef slang.Result Result;
-typedef intptr_t Int;
-typedef uintptr_t UInt;
-typedef uint64_t DeviceAddress;
-typedef int GfxIndex;
-typedef int GfxCount;
-typedef intptr_t Size;
-typedef intptr_t Offset;
+public typedef intptr_t Int;
+public typedef uintptr_t UInt;
+public typedef uint64_t DeviceAddress;
+public typedef int GfxIndex;
+public typedef int GfxCount;
+public typedef intptr_t Size;
+public typedef intptr_t Offset;
-const uint64_t kTimeoutInfinite = 0xFFFFFFFFFFFFFFFF;
+public const uint64_t kTimeoutInfinite = 0xFFFFFFFFFFFFFFFF;
-enum class StructType
+public enum class StructType
{
D3D12ExtendedDesc,
};
-enum class StageType
+public enum class StageType
{
Unknown,
Vertex,
@@ -39,7 +39,7 @@ enum class StageType
CountOf,
};
-enum class DeviceType
+public enum class DeviceType
{
Unknown,
Default,
@@ -52,7 +52,7 @@ enum class DeviceType
CountOf,
};
-enum class ProjectionStyle
+public enum class ProjectionStyle
{
Unknown,
OpenGl,
@@ -61,7 +61,7 @@ enum class ProjectionStyle
CountOf,
};
-enum class BindingStyle
+public enum class BindingStyle
{
Unknown,
DirectX,
@@ -72,17 +72,17 @@ enum class BindingStyle
CountOf,
};
-enum class AccessFlag
+public enum class AccessFlag
{
None,
Read,
Write,
};
-static const GfxCount kMaxRenderTargetCount = 8;
+public static const GfxCount kMaxRenderTargetCount = 8;
// Defines how linking should be performed for a shader program.
-enum class LinkingStyle
+public enum class LinkingStyle
{
// Compose all entry-points in a single program, then compile all entry-points together with the same
// set of root shader arguments.
@@ -92,7 +92,7 @@ enum class LinkingStyle
SeparateEntryPointCompilation
};
-enum class ShaderModuleSourceType
+public enum class ShaderModuleSourceType
{
SlangSource, // a slang source string in memory.
SlangModuleBinary, // a slang module binary code in memory.
@@ -100,27 +100,27 @@ enum class ShaderModuleSourceType
SlangModuleBinaryFile, // a slang module binary code from file.
};
-struct ShaderProgramDesc2
+public struct ShaderProgramDesc2
{
- ShaderModuleSourceType sourceType;
- void *sourceData;
- Size sourceDataSize;
+ public ShaderModuleSourceType sourceType;
+ public void *sourceData;
+ public Size sourceDataSize;
// Number of entry points to include in the shader program. 0 means include all entry points
// defined in the module.
- GfxCount entryPointCount = 0;
+ public GfxCount entryPointCount = 0;
// Names of entry points to include in the shader program. The size of the array must be
// `entryPointCount`.
- NativeString* entryPointNames = nullptr;
+ public NativeString* entryPointNames = nullptr;
};
[COM("9d32d0ad-915c-4ffd-91e2-508554a04a76")]
-interface IShaderProgram
+public interface IShaderProgram
{
- slang::TypeReflection* findTypeByName(NativeString name);
+ public slang::TypeReflection* findTypeByName(NativeString name);
};
-enum class Format
+public enum class Format
{
// D3D formats omitted: 19-22, 44-47, 65-66, 68-70, 73, 76, 79, 82, 88-89, 92-94, 97, 100-114
// These formats are omitted due to lack of a corresponding Vulkan format. D24_UNORM_S8_UINT (DXGI_FORMAT 45)
@@ -228,49 +228,49 @@ enum class Format
_Count,
};
-struct FormatInfo
+public struct FormatInfo
{
- GfxCount channelCount; ///< The amount of channels in the format. Only set if the channelType is set
- uint8_t channelType; ///< One of SlangScalarType None if type isn't made up of elements of type. TODO: Change to uint32_t?
+ public GfxCount channelCount; ///< The amount of channels in the format. Only set if the channelType is set
+ public uint8_t channelType; ///< One of SlangScalarType None if type isn't made up of elements of type. TODO: Change to uint32_t?
- Size blockSizeInBytes; ///< The size of a block in bytes.
- GfxCount pixelsPerBlock; ///< The number of pixels contained in a block.
- GfxCount blockWidth; ///< The width of a block in pixels.
- GfxCount blockHeight; ///< The height of a block in pixels.
+ public Size blockSizeInBytes; ///< The size of a block in bytes.
+ public GfxCount pixelsPerBlock; ///< The number of pixels contained in a block.
+ public GfxCount blockWidth; ///< The width of a block in pixels.
+ public GfxCount blockHeight; ///< The height of a block in pixels.
};
-enum class InputSlotClass
+public enum class InputSlotClass
{
PerVertex, PerInstance
};
-struct InputElementDesc
+public struct InputElementDesc
{
- NativeString semanticName; ///< The name of the corresponding parameter in shader code.
- GfxIndex semanticIndex; ///< The index of the corresponding parameter in shader code. Only needed if multiple parameters share a semantic name.
- Format format; ///< The format of the data being fetched for this element.
- Offset offset; ///< The offset in bytes of this element from the start of the corresponding chunk of vertex stream data.
- GfxIndex bufferSlotIndex; ///< The index of the vertex stream to fetch this element's data from.
+ public NativeString semanticName; ///< The name of the corresponding parameter in shader code.
+ public GfxIndex semanticIndex; ///< The index of the corresponding parameter in shader code. Only needed if multiple parameters share a semantic name.
+ public Format format; ///< The format of the data being fetched for this element.
+ public Offset offset; ///< The offset in bytes of this element from the start of the corresponding chunk of vertex stream data.
+ public GfxIndex bufferSlotIndex; ///< The index of the vertex stream to fetch this element's data from.
};
-struct VertexStreamDesc
+public struct VertexStreamDesc
{
- Size stride; ///< The stride in bytes for this vertex stream.
- InputSlotClass slotClass; ///< Whether the stream contains per-vertex or per-instance data.
- GfxCount instanceDataStepRate; ///< How many instances to draw per chunk of data.
+ public Size stride; ///< The stride in bytes for this vertex stream.
+ public InputSlotClass slotClass; ///< Whether the stream contains per-vertex or per-instance data.
+ public GfxCount instanceDataStepRate; ///< How many instances to draw per chunk of data.
};
-enum class PrimitiveType
+public enum class PrimitiveType
{
Point, Line, Triangle, Patch
};
-enum class PrimitiveTopology
+public enum class PrimitiveTopology
{
TriangleList, TriangleStrip, PointList, LineList, LineStrip
};
-enum class ResourceState
+public enum class ResourceState
{
Undefined,
General,
@@ -295,19 +295,19 @@ enum class ResourceState
_Count
};
-struct ResourceStateSet
+public struct ResourceStateSet
{
- uint64_t m_bitFields;
+ public uint64_t m_bitFields;
[mutating]
- void add(ResourceState state) { m_bitFields |= (1LL << (uint32_t)state); }
+ public void add(ResourceState state) { m_bitFields |= (1LL << (uint32_t)state); }
- bool contains(ResourceState state) { return (m_bitFields & (1LL << (uint32_t)state)) != 0; }
- __init() { m_bitFields = 0; }
- __init(ResourceState state) { add(state); }
+ public bool contains(ResourceState state) { return (m_bitFields & (1LL << (uint32_t)state)) != 0; }
+ public __init() { m_bitFields = 0; }
+ public __init(ResourceState state) { add(state); }
};
-ResourceStateSet operator &(ResourceStateSet val, ResourceStateSet that)
+public ResourceStateSet operator &(ResourceStateSet val, ResourceStateSet that)
{
ResourceStateSet result;
result.m_bitFields = val.m_bitFields & that.m_bitFields;
@@ -315,14 +315,14 @@ ResourceStateSet operator &(ResourceStateSet val, ResourceStateSet that)
}
/// Describes how memory for the resource should be allocated for CPU access.
-enum class MemoryType
+public enum class MemoryType
{
DeviceLocal,
Upload,
ReadBack,
};
-enum class InteropHandleAPI
+public enum class InteropHandleAPI
{
Unknown,
D3D12, // A D3D12 object pointer.
@@ -334,29 +334,29 @@ enum class InteropHandleAPI
D3D12CpuDescriptorHandle, // A D3D12_CPU_DESCRIPTOR_HANDLE value.
};
-struct InteropHandle
+public struct InteropHandle
{
- InteropHandleAPI api = InteropHandleAPI::Unknown;
- uint64_t handleValue;
+ public InteropHandleAPI api = InteropHandleAPI::Unknown;
+ public uint64_t handleValue;
};
// Declare opaque type
-struct InputLayoutDesc
+public struct InputLayoutDesc
{
- InputElementDesc *inputElements;
- GfxCount inputElementCount;
- VertexStreamDesc *vertexStreams;
- GfxCount vertexStreamCount;
+ public InputElementDesc *inputElements;
+ public GfxCount inputElementCount;
+ public VertexStreamDesc *vertexStreams;
+ public GfxCount vertexStreamCount;
};
[COM("45223711-a84b-455c-befa-4937421e8e2e")]
-interface IInputLayout
+public interface IInputLayout
{
};
/// The type of resource.
/// NOTE! The order needs to be such that all texture types are at or after Texture1D (otherwise isTexture won't work correctly)
-enum class ResourceType
+public enum class ResourceType
{
Unknown, ///< Unknown
Buffer, ///< A buffer (like a constant/index/vertex buffer)
@@ -368,86 +368,86 @@ enum class ResourceType
};
/// Base class for Descs
-struct ResourceDescBase
+public struct ResourceDescBase
{
- ResourceType type;
- ResourceState defaultState;
- ResourceStateSet allowedStates;
- MemoryType memoryType;
- InteropHandle existingHandle;
- bool isShared;
+ public ResourceType type;
+ public ResourceState defaultState;
+ public ResourceStateSet allowedStates;
+ public MemoryType memoryType;
+ public InteropHandle existingHandle;
+ public bool isShared;
};
[COM("a0e39f34-8398-4522-95c2-ebc0f984ef3f")]
-interface IResource
+public interface IResource
{
- ResourceType getType();
- Result getNativeResourceHandle(out InteropHandle outHandle);
- Result getSharedHandle(out InteropHandle outHandle);
- Result setDebugName(NativeString name);
- NativeString getDebugName();
+ public ResourceType getType();
+ public Result getNativeResourceHandle(out InteropHandle outHandle);
+ public Result getSharedHandle(out InteropHandle outHandle);
+ public Result setDebugName(NativeString name);
+ public NativeString getDebugName();
};
-struct MemoryRange
+public struct MemoryRange
{
// TODO: Change to Offset/Size?
- uint64_t offset;
- uint64_t size;
+ public uint64_t offset;
+ public uint64_t size;
};
-struct BufferResourceDesc : ResourceDescBase
+public struct BufferResourceDesc : ResourceDescBase
{
- Size sizeInBytes = 0; ///< Total size in bytes
- Size elementSize = 0; ///< Get the element stride. If > 0, this is a structured buffer
- Format format = Format::Unknown;
+ public Size sizeInBytes = 0; ///< Total size in bytes
+ public Size elementSize = 0; ///< Get the element stride. If > 0, this is a structured buffer
+ public Format format = Format::Unknown;
};
[COM("1b274efe-5e37-492b-826e-7ee7e8f5a49b")]
-interface IBufferResource : IResource
+public interface IBufferResource : IResource
{
- BufferResourceDesc *getDesc();
- DeviceAddress getDeviceAddress();
- Result map(MemoryRange* rangeToRead, void** outPointer);
- Result unmap(MemoryRange* writtenRange);
+ public BufferResourceDesc *getDesc();
+ public DeviceAddress getDeviceAddress();
+ public Result map(MemoryRange *rangeToRead, void **outPointer);
+ public Result unmap(MemoryRange* writtenRange);
};
-struct DepthStencilClearValue
+public struct DepthStencilClearValue
{
- float depth = 1.0f;
- uint32_t stencil = 0;
+ public float depth = 1.0f;
+ public uint32_t stencil = 0;
};
-struct ColorClearValue
+public struct ColorClearValue
{
- float4 values;
+ public float4 values;
[mutating]
- void setValue(uint4 uintVal)
+ public void setValue(uint4 uintVal)
{
values = reinterpret<float4, uint4>(uintVal);
}
[mutating]
- void setValue(float4 floatVal)
+ public void setValue(float4 floatVal)
{
values = floatVal;
}
};
-struct ClearValue
+public struct ClearValue
{
- ColorClearValue color;
- DepthStencilClearValue depthStencil;
+ public ColorClearValue color;
+ public DepthStencilClearValue depthStencil;
};
-struct BufferRange
+public struct BufferRange
{
// TODO: Change to Index and Count?
- uint64_t firstElement;
- uint64_t elementCount;
+ public uint64_t firstElement;
+ public uint64_t elementCount;
};
-enum class TextureAspect : uint32_t
+public enum class TextureAspect : uint32_t
{
Default = 0,
Color = 0x00000001,
@@ -461,32 +461,32 @@ enum class TextureAspect : uint32_t
DepthStencil = 0x6,
};
-struct SubresourceRange
+public struct SubresourceRange
{
- TextureAspect aspectMask;
- GfxIndex mipLevel;
- GfxCount mipLevelCount;
- GfxIndex baseArrayLayer; // For Texture3D, this is WSlice.
- GfxCount layerCount; // For cube maps, this is a multiple of 6.
+ public TextureAspect aspectMask;
+ public GfxIndex mipLevel;
+ public GfxCount mipLevelCount;
+ public GfxIndex baseArrayLayer; // For Texture3D, this is WSlice.
+ public GfxCount layerCount; // For cube maps, this is a multiple of 6.
};
-static const Size kRemainingTextureSize = 0xFFFFFFFF;
-struct TextureResourceSampleDesc
+public static const Size kRemainingTextureSize = 0xFFFFFFFF;
+public struct TextureResourceSampleDesc
{
- GfxCount numSamples; ///< Number of samples per pixel
- int quality; ///< The quality measure for the samples
+ public GfxCount numSamples; ///< Number of samples per pixel
+ public int quality; ///< The quality measure for the samples
};
-struct TextureResourceDesc : ResourceDescBase
+public struct TextureResourceDesc : ResourceDescBase
{
- int3 size;
+ public int3 size;
- GfxCount arraySize = 0; ///< Array size
+ public GfxCount arraySize = 0; ///< Array size
- GfxCount numMipLevels = 0; ///< Number of mip levels - if 0 will create all mip levels
- Format format; ///< The resources format
- TextureResourceSampleDesc sampleDesc; ///< How the resource is sampled
- ClearValue* optimalClearValue;
+ public GfxCount numMipLevels = 0; ///< Number of mip levels - if 0 will create all mip levels
+ public Format format; ///< The resources format
+ public TextureResourceSampleDesc sampleDesc; ///< How the resource is sampled
+ public ClearValue* optimalClearValue;
};
/// Data for a single subresource of a texture.
@@ -508,10 +508,10 @@ struct TextureResourceDesc : ResourceDescBase
/// the index of a subresoruce for mip level `m` and array
/// index `a` is `m + a*mipLevelCount`.
///
-struct SubresourceData
+public struct SubresourceData
{
/// Pointer to texel data for the subresource tensor.
- void *data;
+ public void *data;
/// Stride in bytes between rows of the subresource tensor.
///
@@ -521,7 +521,7 @@ struct SubresourceData
/// Devices may not support all possible values for `strideY`.
/// In particular, they may only support strictly positive strides.
///
- gfx::Size strideY;
+ public gfx::Size strideY;
/// Stride in bytes between layers of the subresource tensor.
///
@@ -531,16 +531,16 @@ struct SubresourceData
/// Devices may not support all possible values for `strideZ`.
/// In particular, they may only support strictly positive strides.
///
- gfx::Size strideZ;
+ public gfx::Size strideZ;
};
[COM("cf88a31c-6187-46c5-a4b7-eb-58-c7-33-40-17")]
-interface ITextureResource : IResource
+public interface ITextureResource : IResource
{
- TextureResourceDesc* getDesc();
+ public TextureResourceDesc* getDesc();
};
-enum class ComparisonFunc : uint8_t
+public enum class ComparisonFunc : uint8_t
{
Never = 0x0,
Less = 0x1,
@@ -552,13 +552,13 @@ enum class ComparisonFunc : uint8_t
Always = 0x7,
};
-enum class TextureFilteringMode
+public enum class TextureFilteringMode
{
Point,
Linear,
};
-enum class TextureAddressingMode
+public enum class TextureAddressingMode
{
Wrap,
ClampToEdge,
@@ -567,7 +567,7 @@ enum class TextureAddressingMode
MirrorOnce,
};
-enum class TextureReductionOp
+public enum class TextureReductionOp
{
Average,
Comparison,
@@ -575,22 +575,22 @@ enum class TextureReductionOp
Maximum,
};
-struct SamplerStateDesc
-{
- TextureFilteringMode minFilter;
- TextureFilteringMode magFilter;
- TextureFilteringMode mipFilter;
- TextureReductionOp reductionOp;
- TextureAddressingMode addressU;
- TextureAddressingMode addressV;
- TextureAddressingMode addressW;
- float mipLODBias;
- uint32_t maxAnisotropy;
- ComparisonFunc comparisonFunc;
- float4 borderColor;
- float minLOD;
- float maxLOD;
- __init()
+public struct SamplerStateDesc
+{
+ public TextureFilteringMode minFilter;
+ public TextureFilteringMode magFilter;
+ public TextureFilteringMode mipFilter;
+ public TextureReductionOp reductionOp;
+ public TextureAddressingMode addressU;
+ public TextureAddressingMode addressV;
+ public TextureAddressingMode addressW;
+ public float mipLODBias;
+ public uint32_t maxAnisotropy;
+ public ComparisonFunc comparisonFunc;
+ public float4 borderColor;
+ public float minLOD;
+ public float maxLOD;
+ public __init()
{
minFilter = TextureFilteringMode::Linear;
magFilter = TextureFilteringMode::Linear;
@@ -609,15 +609,15 @@ struct SamplerStateDesc
};
[COM("8b8055df-9377-401d-91ff-3f-a3-bf-66-64-f4")]
-interface ISamplerState
+public interface ISamplerState
{
/// Returns a native API handle representing this sampler state object.
/// When using D3D12, this will be a D3D12_CPU_DESCRIPTOR_HANDLE.
/// When using Vulkan, this will be a VkSampler.
- Result getNativeHandle(InteropHandle *outNativeHandle);
+ public Result getNativeHandle(InteropHandle *outNativeHandle);
};
-enum class ResourceViewType
+public enum class ResourceViewType
{
Unknown,
@@ -630,49 +630,49 @@ enum class ResourceViewType
CountOf_,
};
-struct RenderTargetDesc
+public struct RenderTargetDesc
{
// The resource shape of this render target view.
- ResourceType shape;
+ public ResourceType shape;
};
-struct ResourceViewDesc
+public struct ResourceViewDesc
{
- ResourceViewType type;
- Format format;
+ public ResourceViewType type;
+ public Format format;
// Required fields for `RenderTarget` and `DepthStencil` views.
- RenderTargetDesc renderTarget;
+ public RenderTargetDesc renderTarget;
// Specifies the range of a texture resource for a ShaderRsource/UnorderedAccess/RenderTarget/DepthStencil view.
- SubresourceRange subresourceRange;
+ public SubresourceRange subresourceRange;
// Specifies the range of a buffer resource for a ShaderResource/UnorderedAccess view.
- BufferRange bufferRange;
+ public BufferRange bufferRange;
// Specifies the element size in bytes of a structured buffer. Pass 0 for a raw buffer view.
- Size bufferElementSize;
+ public Size bufferElementSize;
};
[COM("7b6c4926-0884-408c-ad8a-50-3a-8e-23-98-a4")]
-interface IResourceView
+public interface IResourceView
{
- ResourceViewDesc* getViewDesc();
+ public ResourceViewDesc* getViewDesc();
/// Returns a native API handle representing this resource view object.
/// When using D3D12, this will be a D3D12_CPU_DESCRIPTOR_HANDLE or a buffer device address depending
/// on the type of the resource view.
/// When using Vulkan, this will be a VkImageView, VkBufferView, VkAccelerationStructure or a VkBuffer
/// depending on the type of the resource view.
- Result getNativeHandle(InteropHandle *outNativeHandle);
+ public Result getNativeHandle(InteropHandle *outNativeHandle);
};
-enum class AccelerationStructureKind
+public enum class AccelerationStructureKind
{
TopLevel,
BottomLevel
};
-// The enum values are intentionally consistent with
+// The public enum values are intentionally consistent with
// D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS.
-enum AccelerationStructureBuildFlags
+public enum AccelerationStructureBuildFlags
{
None,
AllowUpdate = 1,
@@ -683,16 +683,16 @@ enum AccelerationStructureBuildFlags
PerformUpdate = 32
};
-enum class GeometryType
+public enum class GeometryType
{
Triangles, ProcedurePrimitives
};
-struct GeometryFlags
+public struct GeometryFlags
{
- // The enum values are intentionally consistent with
+ // The public enum values are intentionally consistent with
// D3D12_RAYTRACING_GEOMETRY_FLAGS.
- enum Enum
+ public enum Enum
{
None,
Opaque = 1,
@@ -700,55 +700,55 @@ struct GeometryFlags
};
};
-struct TriangleDesc
+public struct TriangleDesc
{
- DeviceAddress transform3x4;
- Format indexFormat;
- Format vertexFormat;
- GfxCount indexCount;
- GfxCount vertexCount;
- DeviceAddress indexData;
- DeviceAddress vertexData;
- Size vertexStride;
+ public DeviceAddress transform3x4;
+ public Format indexFormat;
+ public Format vertexFormat;
+ public GfxCount indexCount;
+ public GfxCount vertexCount;
+ public DeviceAddress indexData;
+ public DeviceAddress vertexData;
+ public Size vertexStride;
};
-struct ProceduralAABB
+public struct ProceduralAABB
{
- float minX;
- float minY;
- float minZ;
- float maxX;
- float maxY;
- float maxZ;
+ public float minX;
+ public float minY;
+ public float minZ;
+ public float maxX;
+ public float maxY;
+ public float maxZ;
};
-struct ProceduralAABBDesc
+public struct ProceduralAABBDesc
{
/// Number of AABBs.
- GfxCount count;
+ public GfxCount count;
/// Pointer to an array of `ProceduralAABB` values in device memory.
- DeviceAddress data;
+ public DeviceAddress data;
/// Stride in bytes of the AABB values array.
- Size stride;
+ public Size stride;
};
-struct GeometryDesc
+public struct GeometryDesc
{
- GeometryType type;
- GeometryFlags::Enum flags;
- TriangleDesc triangles;
- property ProceduralAABBDesc proceduralAABBs
+ public GeometryType type;
+ public GeometryFlags::Enum flags;
+ public TriangleDesc triangles;
+ public property ProceduralAABBDesc proceduralAABBs
{
get { return reinterpret<ProceduralAABBDesc, TriangleDesc>(triangles); }
set { triangles = reinterpret<TriangleDesc, ProceduralAABBDesc>(newValue); }
}
};
-// The enum values are kept consistent with D3D12_RAYTRACING_INSTANCE_FLAGS
+// The public enum values are kept consistent with D3D12_RAYTRACING_INSTANCE_FLAGS
// and VkGeometryInstanceFlagBitsKHR.
-enum GeometryInstanceFlags
+public enum GeometryInstanceFlags
{
None = 0,
TriangleFacingCullDisable = 0x00000001,
@@ -758,141 +758,141 @@ enum GeometryInstanceFlags
};
// TODO: Should any of these be changed?
-// The layout of this struct is intentionally consistent with D3D12_RAYTRACING_INSTANCE_DESC
+// The layout of this public struct is intentionally consistent with D3D12_RAYTRACING_INSTANCE_DESC
// and VkAccelerationStructureInstanceKHR.
-struct InstanceDesc
+public struct InstanceDesc
{
- float transform[3][4];
- uint32_t instanceID24_mask8;
- property uint32_t instanceID { get { return instanceID24_mask8 & 0xFFFFFF; } set { instanceID24_mask8 = (instanceID24_mask8 & 0xFF000000) | (newValue & 0xFFFFFF); } }
- property uint32_t instanceMask { get { return instanceID24_mask8 >> 24; } set { instanceID24_mask8 = (newValue << 24) | (instanceID24_mask8 & 0x00FFFFFF); } }
+ public float transform[3][4];
+ public uint32_t instanceID24_mask8;
+ public property uint32_t instanceID { get { return instanceID24_mask8 & 0xFFFFFF; } set { instanceID24_mask8 = (instanceID24_mask8 & 0xFF000000) | (newValue & 0xFFFFFF); } }
+ public property uint32_t instanceMask { get { return instanceID24_mask8 >> 24; } set { instanceID24_mask8 = (newValue << 24) | (instanceID24_mask8 & 0x00FFFFFF); } }
- uint32_t instanceContributionToHitGroupIndex24_flags8;
- property uint32_t instanceContributionToHitGroupIndex
+ public uint32_t instanceContributionToHitGroupIndex24_flags8;
+ public property uint32_t instanceContributionToHitGroupIndex
{
get { return instanceContributionToHitGroupIndex24_flags8 & 0xFFFFFF; }
set { instanceContributionToHitGroupIndex24_flags8 = (instanceContributionToHitGroupIndex24_flags8 & 0xFF000000) | (newValue & 0xFFFFFF); }
}
- property GeometryInstanceFlags flags
+ public property GeometryInstanceFlags flags
{
get { return (GeometryInstanceFlags)(instanceContributionToHitGroupIndex24_flags8 >> 24); }
set { instanceContributionToHitGroupIndex24_flags8 = ((uint32_t)newValue << 24) | (instanceContributionToHitGroupIndex24_flags8 & 0x00FFFFFF); }
}
- DeviceAddress accelerationStructure;
+ public DeviceAddress accelerationStructure;
};
-struct AccelerationStructurePrebuildInfo
+public struct AccelerationStructurePrebuildInfo
{
- Size resultDataMaxSize;
- Size scratchDataSize;
- Size updateScratchDataSize;
+ public Size resultDataMaxSize;
+ public Size scratchDataSize;
+ public Size updateScratchDataSize;
};
-struct AccelerationStructureBuildInputs
+public struct AccelerationStructureBuildInputs
{
- AccelerationStructureKind kind;
+ public AccelerationStructureKind kind;
- AccelerationStructureBuildFlags flags;
+ public AccelerationStructureBuildFlags flags;
- GfxCount descCount;
+ public GfxCount descCount;
/// Array of `InstanceDesc` values in device memory.
/// Used when `kind` is `TopLevel`.
- DeviceAddress instanceDescs;
+ public DeviceAddress instanceDescs;
/// Array of `GeometryDesc` values.
/// Used when `kind` is `BottomLevel`.
- GeometryDesc *geometryDescs;
+ public GeometryDesc *geometryDescs;
};
-struct AccelerationStructureCreateDesc
+public struct AccelerationStructureCreateDesc
{
- AccelerationStructureKind kind;
- NativeRef<IBufferResource> buffer;
- Offset offset;
- Size size;
+ public AccelerationStructureKind kind;
+ public NativeRef<IBufferResource> buffer;
+ public Offset offset;
+ public Size size;
};
-struct AccelerationStructureBuildDesc
+public struct AccelerationStructureBuildDesc
{
- AccelerationStructureBuildInputs inputs;
- NativeRef<IAccelerationStructure> source;
- NativeRef<IAccelerationStructure> dest;
- DeviceAddress scratchData;
+ public AccelerationStructureBuildInputs inputs;
+ public NativeRef<IAccelerationStructure> source;
+ public NativeRef<IAccelerationStructure> dest;
+ public DeviceAddress scratchData;
};
[COM("a5cdda3c-1d4e-4df7-8ef2-b7-3f-ce-04-de-3b")]
-interface IAccelerationStructure : IResourceView
+public interface IAccelerationStructure : IResourceView
{
- DeviceAddress getDeviceAddress();
+ public DeviceAddress getDeviceAddress();
};
-struct FenceDesc
+public struct FenceDesc
{
- uint64_t initialValue;
- bool isShared;
+ public uint64_t initialValue;
+ public bool isShared;
};
[COM("7fe1c283-d3f4-48ed-aaf3-01-51-96-4e-7c-b5")]
-interface IFence
+public interface IFence
{
/// Returns the currently signaled value on the device.
- Result getCurrentValue(uint64_t *outValue);
+ public Result getCurrentValue(uint64_t *outValue);
/// Signals the fence from the host with the specified value.
- Result setCurrentValue(uint64_t value);
+ public Result setCurrentValue(uint64_t value);
- Result getSharedHandle(InteropHandle *outHandle);
- Result getNativeHandle(InteropHandle *outNativeHandle);
+ public Result getSharedHandle(InteropHandle *outHandle);
+ public Result getNativeHandle(InteropHandle *outNativeHandle);
};
-struct ShaderOffset
+public struct ShaderOffset
{
- Int uniformOffset = 0; // TODO: Change to Offset?
- GfxIndex bindingRangeIndex = 0;
- GfxIndex bindingArrayIndex = 0;
+ public Int uniformOffset = 0; // TODO: Change to Offset?
+ public GfxIndex bindingRangeIndex = 0;
+ public GfxIndex bindingArrayIndex = 0;
}
-enum class ShaderObjectContainerType
+public enum class ShaderObjectContainerType
{
None, Array, StructuredBuffer
};
[COM("c1fa997e-5ca2-45ae-9bcb-c4-35-9e-85-05-85")]
-interface IShaderObject
-{
- slang::TypeLayoutReflection* getElementTypeLayout();
- ShaderObjectContainerType getContainerType();
- GfxCount getEntryPointCount();
- Result getEntryPoint(GfxIndex index, out Optional<IShaderObject> entryPoint);
- Result setData(ShaderOffset *offset, void *data, Size size);
- Result getObject(ShaderOffset *offset, out Optional<IShaderObject> object);
- Result setObject(ShaderOffset* offset, IShaderObject object);
- Result setResource(ShaderOffset* offset, IResourceView resourceView);
- Result setSampler(ShaderOffset* offset, ISamplerState sampler);
- Result setCombinedTextureSampler(ShaderOffset* offset, IResourceView textureView, ISamplerState sampler);
+public interface IShaderObject
+{
+ public slang::TypeLayoutReflection* getElementTypeLayout();
+ public ShaderObjectContainerType getContainerType();
+ public GfxCount getEntryPointCount();
+ public Result getEntryPoint(GfxIndex index, out Optional<IShaderObject> entryPoint);
+ public Result setData(ShaderOffset *offset, void *data, Size size);
+ public Result getObject(ShaderOffset *offset, out Optional<IShaderObject> object);
+ public Result setObject(ShaderOffset* offset, IShaderObject object);
+ public Result setResource(ShaderOffset* offset, IResourceView resourceView);
+ public Result setSampler(ShaderOffset* offset, ISamplerState sampler);
+ public Result setCombinedTextureSampler(ShaderOffset* offset, IResourceView textureView, ISamplerState sampler);
/// Manually overrides the specialization argument for the sub-object binding at `offset`.
/// Specialization arguments are passed to the shader compiler to specialize the type
/// of interface-typed shader parameters.
- Result setSpecializationArgs(
+ public Result setSpecializationArgs(
ShaderOffset* offset,
slang::SpecializationArg *args,
GfxCount count);
- Result getCurrentVersion(
+ public Result getCurrentVersion(
ITransientResourceHeap transientHeap,
out IShaderObject outObject);
- void* getRawData();
+ public void* getRawData();
- Size getSize();
+ public Size getSize();
/// Use the provided constant buffer instead of the internally created one.
- Result setConstantBufferOverride(IBufferResource constantBuffer);
+ public Result setConstantBufferOverride(IBufferResource constantBuffer);
};
-enum class StencilOp : uint8_t
+public enum class StencilOp : uint8_t
{
Keep,
Zero,
@@ -904,32 +904,32 @@ enum class StencilOp : uint8_t
DecrementWrap,
};
-enum class FillMode : uint8_t
+public enum class FillMode : uint8_t
{
Solid,
Wireframe,
};
-enum class CullMode : uint8_t
+public enum class CullMode : uint8_t
{
None,
Front,
Back,
};
-enum class FrontFaceMode : uint8_t
+public enum class FrontFaceMode : uint8_t
{
CounterClockwise,
Clockwise,
};
-struct DepthStencilOpDesc
+public struct DepthStencilOpDesc
{
- StencilOp stencilFailOp = StencilOp::Keep;
- StencilOp stencilDepthFailOp = StencilOp::Keep;
- StencilOp stencilPassOp = StencilOp::Keep;
- ComparisonFunc stencilFunc = ComparisonFunc::Always;
- __init()
+ public StencilOp stencilFailOp = StencilOp::Keep;
+ public StencilOp stencilDepthFailOp = StencilOp::Keep;
+ public StencilOp stencilPassOp = StencilOp::Keep;
+ public ComparisonFunc stencilFunc = ComparisonFunc::Always;
+ public __init()
{
stencilFailOp = StencilOp::Keep;
stencilDepthFailOp = StencilOp::Keep;
@@ -938,21 +938,21 @@ struct DepthStencilOpDesc
}
};
-struct DepthStencilDesc
+public struct DepthStencilDesc
{
- bool depthTestEnable = false;
- bool depthWriteEnable = true;
- ComparisonFunc depthFunc = ComparisonFunc::Less;
+ public bool depthTestEnable = false;
+ public bool depthWriteEnable = true;
+ public ComparisonFunc depthFunc = ComparisonFunc::Less;
- bool stencilEnable = false;
- uint32_t stencilReadMask = 0xFFFFFFFF;
- uint32_t stencilWriteMask = 0xFFFFFFFF;
- DepthStencilOpDesc frontFace;
- DepthStencilOpDesc backFace;
+ public bool stencilEnable = false;
+ public uint32_t stencilReadMask = 0xFFFFFFFF;
+ public uint32_t stencilWriteMask = 0xFFFFFFFF;
+ public DepthStencilOpDesc frontFace;
+ public DepthStencilOpDesc backFace;
- uint32_t stencilRef = 0;
+ public uint32_t stencilRef = 0;
- __init()
+ public __init()
{
depthTestEnable = false;
depthWriteEnable = true;
@@ -964,22 +964,22 @@ struct DepthStencilDesc
}
};
-struct RasterizerDesc
+public struct RasterizerDesc
{
- FillMode fillMode = FillMode::Solid;
- CullMode cullMode = CullMode::None;
- FrontFaceMode frontFace = FrontFaceMode::CounterClockwise;
- int32_t depthBias = 0;
- float depthBiasClamp = 0.0f;
- float slopeScaledDepthBias = 0.0f;
- bool depthClipEnable = true;
- bool scissorEnable = false;
- bool multisampleEnable = false;
- bool antialiasedLineEnable = false;
- bool enableConservativeRasterization = false;
- uint32_t forcedSampleCount = 0;
+ public FillMode fillMode = FillMode::Solid;
+ public CullMode cullMode = CullMode::None;
+ public FrontFaceMode frontFace = FrontFaceMode::CounterClockwise;
+ public int32_t depthBias = 0;
+ public float depthBiasClamp = 0.0f;
+ public float slopeScaledDepthBias = 0.0f;
+ public bool depthClipEnable = true;
+ public bool scissorEnable = false;
+ public bool multisampleEnable = false;
+ public bool antialiasedLineEnable = false;
+ public bool enableConservativeRasterization = false;
+ public uint32_t forcedSampleCount = 0;
- __init()
+ public __init()
{
fillMode = FillMode::Solid;
cullMode = CullMode::None;
@@ -996,12 +996,12 @@ struct RasterizerDesc
}
};
-enum class LogicOp
+public enum class LogicOp
{
NoOp,
};
-enum class BlendOp
+public enum class BlendOp
{
Add,
Subtract,
@@ -1010,7 +1010,7 @@ enum class BlendOp
Max,
};
-enum class BlendFactor
+public enum class BlendFactor
{
Zero,
One,
@@ -1031,7 +1031,7 @@ enum class BlendFactor
InvSecondarySrcAlpha,
};
-enum RenderTargetWriteMask
+public enum RenderTargetWriteMask
{
EnableNone = 0,
EnableRed = 0x01,
@@ -1041,11 +1041,11 @@ enum RenderTargetWriteMask
EnableAll = 0x0F,
};
-struct AspectBlendDesc
+public struct AspectBlendDesc
{
- BlendFactor srcFactor = BlendFactor::One;
- BlendFactor dstFactor = BlendFactor::Zero;
- BlendOp op = BlendOp::Add;
+ public BlendFactor srcFactor = BlendFactor::One;
+ public BlendFactor dstFactor = BlendFactor::Zero;
+ public BlendOp op = BlendOp::Add;
__init()
{
@@ -1054,14 +1054,14 @@ struct AspectBlendDesc
}
};
-struct TargetBlendDesc
+public struct TargetBlendDesc
{
- AspectBlendDesc color;
- AspectBlendDesc alpha;
- bool enableBlend;
- LogicOp logicOp;
- RenderTargetWriteMask writeMask;
- __init()
+ public AspectBlendDesc color;
+ public AspectBlendDesc alpha;
+ public bool enableBlend;
+ public LogicOp logicOp;
+ public RenderTargetWriteMask writeMask;
+ public __init()
{
enableBlend = false;
logicOp = LogicOp::NoOp;
@@ -1069,168 +1069,168 @@ struct TargetBlendDesc
}
};
-struct BlendDesc
+public struct BlendDesc
{
- TargetBlendDesc targets[kMaxRenderTargetCount];
- GfxCount targetCount;
+ public TargetBlendDesc targets[kMaxRenderTargetCount];
+ public GfxCount targetCount;
- bool alphaToCoverageEnable;
+ public bool alphaToCoverageEnable;
};
-struct FramebufferTargetLayout
+public struct FramebufferTargetLayout
{
- Format format;
- GfxCount sampleCount;
+ public Format format;
+ public GfxCount sampleCount;
};
-struct FramebufferLayoutDesc
+public struct FramebufferLayoutDesc
{
- GfxCount renderTargetCount;
- FramebufferTargetLayout *renderTargets;
- FramebufferTargetLayout *depthStencil;
+ public GfxCount renderTargetCount;
+ public FramebufferTargetLayout *renderTargets;
+ public FramebufferTargetLayout *depthStencil;
};
[COM("0a838785-c13a-4832-ad88-64-06-b5-4b-5e-ba")]
-interface IFramebufferLayout
+public interface IFramebufferLayout
{
};
-struct GraphicsPipelineStateDesc
+public struct GraphicsPipelineStateDesc
{
- NativeRef<IShaderProgram> program;
+ public NativeRef<IShaderProgram> program;
- NativeRef<IInputLayout> inputLayout;
- NativeRef<IFramebufferLayout> framebufferLayout;
- PrimitiveType primitiveType;
- DepthStencilDesc depthStencil;
- RasterizerDesc rasterizer;
- BlendDesc blend;
+ public NativeRef<IInputLayout> inputLayout;
+ public NativeRef<IFramebufferLayout> framebufferLayout;
+ public PrimitiveType primitiveType;
+ public DepthStencilDesc depthStencil;
+ public RasterizerDesc rasterizer;
+ public BlendDesc blend;
- __init()
+ public __init()
{
primitiveType = PrimitiveType::Triangle;
}
};
-struct ComputePipelineStateDesc
+public struct ComputePipelineStateDesc
{
- NativeRef<IShaderProgram> program;
- void *d3d12RootSignatureOverride;
+ public NativeRef<IShaderProgram> program;
+ public void *d3d12RootSignatureOverride;
};
-enum RayTracingPipelineFlags
+public enum RayTracingPipelineFlags
{
None = 0,
SkipTriangles = 1,
SkipProcedurals = 2,
};
-struct HitGroupDesc
+public struct HitGroupDesc
{
- NativeString hitGroupName;
- NativeString closestHitEntryPoint;
- NativeString anyHitEntryPoint;
- NativeString intersectionEntryPoint;
+ public NativeString hitGroupName;
+ public NativeString closestHitEntryPoint;
+ public NativeString anyHitEntryPoint;
+ public NativeString intersectionEntryPoint;
};
-struct RayTracingPipelineStateDesc
+public struct RayTracingPipelineStateDesc
{
- NativeRef<IShaderProgram> program;
- GfxCount hitGroupCount = 0;
- HitGroupDesc *hitGroups;
- int maxRecursion = 0;
- Size maxRayPayloadSize = 0;
- Size maxAttributeSizeInBytes = 8;
- RayTracingPipelineFlags flags = RayTracingPipelineFlags::None;
+ public NativeRef<IShaderProgram> program;
+ public GfxCount hitGroupCount = 0;
+ public HitGroupDesc *hitGroups;
+ public int maxRecursion = 0;
+ public Size maxRayPayloadSize = 0;
+ public Size maxAttributeSizeInBytes = 8;
+ public RayTracingPipelineFlags flags = RayTracingPipelineFlags::None;
};
// Specifies the bytes to overwrite into a record in the shader table.
-struct ShaderRecordOverwrite
+public struct ShaderRecordOverwrite
{
- Offset offset; // Offset within the shader record.
- Size size; // Number of bytes to overwrite.
- uint8_t data[8]; // Content to overwrite.
+ public Offset offset; // Offset within the shader record.
+ public Size size; // Number of bytes to overwrite.
+ public uint8_t data[8]; // Content to overwrite.
};
-struct ShaderTableDesc
+public struct ShaderTableDesc
{
- GfxCount rayGenShaderCount;
- NativeString* rayGenShaderEntryPointNames;
- ShaderRecordOverwrite *rayGenShaderRecordOverwrites;
+ public GfxCount rayGenShaderCount;
+ public NativeString* rayGenShaderEntryPointNames;
+ public ShaderRecordOverwrite *rayGenShaderRecordOverwrites;
- GfxCount missShaderCount;
- NativeString* missShaderEntryPointNames;
- ShaderRecordOverwrite *missShaderRecordOverwrites;
+ public GfxCount missShaderCount;
+ public NativeString *missShaderEntryPointNames;
+ public ShaderRecordOverwrite *missShaderRecordOverwrites;
- GfxCount hitGroupCount;
- NativeString* hitGroupNames;
- ShaderRecordOverwrite *hitGroupRecordOverwrites;
+ public GfxCount hitGroupCount;
+ public NativeString *hitGroupNames;
+ public ShaderRecordOverwrite *hitGroupRecordOverwrites;
NativeRef<IShaderProgram> program;
};
[COM("a721522c-df31-4c2f-a5e7-3b-e0-12-4b-31-78")]
-interface IShaderTable
+public interface IShaderTable
{
};
[COM("0ca7e57d-8a90-44f3-bdb1-fe-9b-35-3f-5a-72")]
-interface IPipelineState
+public interface IPipelineState
{
Result getNativeHandle(InteropHandle *outHandle);
};
-struct ScissorRect
+public struct ScissorRect
{
- int32_t minX;
- int32_t minY;
- int32_t maxX;
- int32_t maxY;
+ public int32_t minX;
+ public int32_t minY;
+ public int32_t maxX;
+ public int32_t maxY;
};
-struct Viewport
+public struct Viewport
{
- float originX = 0.0f;
- float originY = 0.0f;
- float extentX = 0.0f;
- float extentY = 0.0f;
- float minZ = 0.0f;
- float maxZ = 1.0f;
+ public float originX = 0.0f;
+ public float originY = 0.0f;
+ public float extentX = 0.0f;
+ public float extentY = 0.0f;
+ public float minZ = 0.0f;
+ public float maxZ = 1.0f;
};
-struct FramebufferDesc
+public struct FramebufferDesc
{
- GfxCount renderTargetCount;
- NativeRef<IResourceView> *renderTargetViews;
- NativeRef<IResourceView> depthStencilView;
- NativeRef<IFramebufferLayout> layout;
+ public GfxCount renderTargetCount;
+ public NativeRef<IResourceView> *renderTargetViews;
+ public NativeRef<IResourceView> depthStencilView;
+ public NativeRef<IFramebufferLayout> layout;
};
[COM("0f0c0d9a-4ef3-4e18-9ba9-34-60-ea-69-87-95")]
-interface IFramebuffer
+public interface IFramebuffer
{
};
-enum class WindowHandleType
+public enum class WindowHandleType
{
Unknown,
Win32Handle,
XLibHandle,
};
-struct WindowHandle
+public struct WindowHandle
{
- WindowHandleType type;
- void* handleValues[2];
- static WindowHandle fromHwnd(void *hwnd)
+ public WindowHandleType type;
+ public void* handleValues[2];
+ public static WindowHandle fromHwnd(void *hwnd)
{
WindowHandle handle = {};
handle.type = WindowHandleType::Win32Handle;
handle.handleValues[0] = hwnd;
return handle;
}
- static WindowHandle fromXWindow(void *xdisplay, uint32_t xwindow)
+ public static WindowHandle fromXWindow(void *xdisplay, uint32_t xwindow)
{
WindowHandle handle = {};
handle.type = WindowHandleType::XLibHandle;
@@ -1240,42 +1240,42 @@ struct WindowHandle
}
};
-enum FaceMask
+public enum FaceMask
{
Front = 1, Back = 2
};
-enum class TargetLoadOp
+public enum class TargetLoadOp
{
Load, Clear, DontCare
};
-enum class TargetStoreOp
+public enum class TargetStoreOp
{
Store, DontCare
};
-struct TargetAccessDesc
+public struct TargetAccessDesc
{
- TargetLoadOp loadOp;
- TargetLoadOp stencilLoadOp;
- TargetStoreOp storeOp;
- TargetStoreOp stencilStoreOp;
- ResourceState initialState;
- ResourceState finalState;
+ public TargetLoadOp loadOp;
+ public TargetLoadOp stencilLoadOp;
+ public TargetStoreOp storeOp;
+ public TargetStoreOp stencilStoreOp;
+ public ResourceState initialState;
+ public ResourceState finalState;
};
-struct RenderPassLayoutDesc
+public struct RenderPassLayoutDesc
{
- NativeRef<IFramebufferLayout> framebufferLayout;
- GfxCount renderTargetCount;
- TargetAccessDesc *renderTargetAccess;
- TargetAccessDesc *depthStencilAccess;
+ public NativeRef<IFramebufferLayout> framebufferLayout;
+ public GfxCount renderTargetCount;
+ public TargetAccessDesc *renderTargetAccess;
+ public TargetAccessDesc *depthStencilAccess;
};
[COM("daab0b1a-f45d-4ae9-bf2c-e0-bb-76-7d-fa-d1")]
-interface IRenderPassLayout
+public interface IRenderPassLayout
{
};
-enum class QueryType
+public enum class QueryType
{
Timestamp,
AccelerationStructureCompactedSize,
@@ -1283,57 +1283,57 @@ enum class QueryType
AccelerationStructureCurrentSize,
};
-struct QueryPoolDesc
+public struct QueryPoolDesc
{
- QueryType type;
- GfxCount count;
+ public QueryType type;
+ public GfxCount count;
};
[COM("c2cc3784-12da-480a-a874-8b-31-96-1c-a4-36")]
-interface IQueryPool
+public interface IQueryPool
{
- Result getResult(GfxIndex queryIndex, GfxCount count, uint64_t *data);
- Result reset();
+ public Result getResult(GfxIndex queryIndex, GfxCount count, uint64_t *data);
+ public Result reset();
};
[COM("77ea6383-be3d-40aa-8b45-fd-f0-d7-5b-fa-34")]
-interface ICommandEncoder
+public interface ICommandEncoder
{
- void endEncoding();
- void writeTimestamp(IQueryPool queryPool, GfxIndex queryIndex);
+ public void endEncoding();
+ public void writeTimestamp(IQueryPool queryPool, GfxIndex queryIndex);
};
-struct IndirectDispatchArguments
+public struct IndirectDispatchArguments
{
- GfxCount ThreadGroupCountX;
- GfxCount ThreadGroupCountY;
- GfxCount ThreadGroupCountZ;
+ public GfxCount ThreadGroupCountX;
+ public GfxCount ThreadGroupCountY;
+ public GfxCount ThreadGroupCountZ;
};
-struct IndirectDrawArguments
+public struct IndirectDrawArguments
{
- GfxCount VertexCountPerInstance;
- GfxCount InstanceCount;
- GfxIndex StartVertexLocation;
- GfxIndex StartInstanceLocation;
+ public GfxCount VertexCountPerInstance;
+ public GfxCount InstanceCount;
+ public GfxIndex StartVertexLocation;
+ public GfxIndex StartInstanceLocation;
};
-struct IndirectDrawIndexedArguments
+public struct IndirectDrawIndexedArguments
{
- GfxCount IndexCountPerInstance;
- GfxCount InstanceCount;
- GfxIndex StartIndexLocation;
- GfxIndex BaseVertexLocation;
- GfxIndex StartInstanceLocation;
+ public GfxCount IndexCountPerInstance;
+ public GfxCount InstanceCount;
+ public GfxIndex StartIndexLocation;
+ public GfxIndex BaseVertexLocation;
+ public GfxIndex StartInstanceLocation;
};
-struct SamplePosition
+public struct SamplePosition
{
- int8_t x;
- int8_t y;
+ public int8_t x;
+ public int8_t y;
};
-enum ClearResourceViewFlags
+public enum ClearResourceViewFlags
{
None = 0,
ClearDepth = 1,
@@ -1342,9 +1342,9 @@ enum ClearResourceViewFlags
};
[COM("F99A00E9-ED50-4088-8A0E-3B26755031EA")]
-interface IResourceCommandEncoder : ICommandEncoder
+public interface IResourceCommandEncoder : ICommandEncoder
{
- void copyBuffer(
+ public void copyBuffer(
IBufferResource dst,
Offset dstOffset,
IBufferResource src,
@@ -1353,7 +1353,7 @@ interface IResourceCommandEncoder : ICommandEncoder
/// Copies texture from src to dst. If dstSubresource and srcSubresource has mipLevelCount = 0
/// and layerCount = 0, the entire resource is being copied and dstOffset, srcOffset and extent
/// arguments are ignored.
- void copyTexture(
+ public void copyTexture(
ITextureResource dst,
ResourceState dstState,
SubresourceRange dstSubresource,
@@ -1365,7 +1365,7 @@ interface IResourceCommandEncoder : ICommandEncoder
int3 extent);
/// Copies texture to a buffer. Each row is aligned to kTexturePitchAlignment.
- void copyTextureToBuffer(
+ public void copyTextureToBuffer(
IBufferResource dst,
Offset dstOffset,
Size dstSize,
@@ -1375,89 +1375,89 @@ interface IResourceCommandEncoder : ICommandEncoder
SubresourceRange srcSubresource,
int3 srcOffset,
int3 extent);
- void uploadTextureData(
+ public void uploadTextureData(
ITextureResource dst,
SubresourceRange subResourceRange,
int3 offset,
int3 extent,
SubresourceData *subResourceData,
GfxCount subResourceDataCount);
- void uploadBufferData(IBufferResource dst, Offset offset, Size size, void *data);
- void textureBarrier(
+ public void uploadBufferData(IBufferResource dst, Offset offset, Size size, void *data);
+ public void textureBarrier(
GfxCount count, NativeRef<ITextureResource> *textures, ResourceState src, ResourceState dst);
- void textureSubresourceBarrier(
+ public void textureSubresourceBarrier(
ITextureResource texture,
SubresourceRange subresourceRange,
ResourceState src,
ResourceState dst);
- void bufferBarrier(
- GfxCount count, NativeRef<IBufferResource>* buffers, ResourceState src, ResourceState dst);
- void clearResourceView(
+ public void bufferBarrier(
+ GfxCount count, NativeRef<IBufferResource> *buffers, ResourceState src, ResourceState dst);
+ public void clearResourceView(
IResourceView view, ClearValue *clearValue, ClearResourceViewFlags flags);
- void resolveResource(
+ public void resolveResource(
ITextureResource source,
ResourceState sourceState,
SubresourceRange sourceRange,
ITextureResource dest,
ResourceState destState,
SubresourceRange destRange);
- void resolveQuery(
+ public void resolveQuery(
IQueryPool queryPool,
GfxIndex index,
GfxCount count,
IBufferResource buffer,
Offset offset);
- void beginDebugEvent(NativeString name, float rgbColor[3]);
- void endDebugEvent();
+ public void beginDebugEvent(NativeString name, float rgbColor[3]);
+ public void endDebugEvent();
};
[COM("7A8D56D0-53E6-4AD6-85F7-D14DC110FDCE")]
-interface IRenderCommandEncoder : IResourceCommandEncoder
+public interface IRenderCommandEncoder : IResourceCommandEncoder
{
// Sets the current pipeline state. This method returns a transient shader object for
// writing shader parameters. This shader object will not retain any resources or
// sub-shader-objects bound to it. The user must be responsible for ensuring that any
// resources or shader objects that is set into `outRootShaderObject` stays alive during
// the execution of the command buffer.
- Result bindPipeline(IPipelineState state, out IShaderObject outRootShaderObject);
+ public Result bindPipeline(IPipelineState state, out IShaderObject outRootShaderObject);
// Sets the current pipeline state along with a pre-created mutable root shader object.
- Result bindPipelineWithRootObject(IPipelineState state, NativeRef<IShaderObject> rootObject);
+ public Result bindPipelineWithRootObject(IPipelineState state, NativeRef<IShaderObject> rootObject);
- void setViewports(GfxCount count, Viewport *viewports);
- void setScissorRects(GfxCount count, ScissorRect *scissors);
+ public void setViewports(GfxCount count, Viewport *viewports);
+ public void setScissorRects(GfxCount count, ScissorRect *scissors);
- void setPrimitiveTopology(PrimitiveTopology topology);
- void setVertexBuffers(
+ public void setPrimitiveTopology(PrimitiveTopology topology);
+ public void setVertexBuffers(
GfxIndex startSlot,
GfxCount slotCount,
NativeRef<IBufferResource>* buffers,
Offset *offsets);
- void setIndexBuffer(IBufferResource buffer, Format indexFormat, Offset offset);
- void draw(GfxCount vertexCount, GfxIndex startVertex);
- void drawIndexed(GfxCount indexCount, GfxIndex startIndex = 0, GfxIndex baseVertex = 0);
- void drawIndirect(
+ public void setIndexBuffer(IBufferResource buffer, Format indexFormat, Offset offset);
+ public void draw(GfxCount vertexCount, GfxIndex startVertex);
+ public void drawIndexed(GfxCount indexCount, GfxIndex startIndex = 0, GfxIndex baseVertex = 0);
+ public void drawIndirect(
GfxCount maxDrawCount,
IBufferResource argBuffer,
Offset argOffset,
NativeRef<IBufferResource> countBuffer,
Offset countOffset = 0);
- void drawIndexedIndirect(
+ public void drawIndexedIndirect(
GfxCount maxDrawCount,
IBufferResource argBuffer,
Offset argOffset,
NativeRef<IBufferResource> countBuffer,
Offset countOffset = 0);
- void setStencilReference(uint32_t referenceValue);
- Result setSamplePositions(
+ public void setStencilReference(uint32_t referenceValue);
+ public Result setSamplePositions(
GfxCount samplesPerPixel, GfxCount pixelCount, SamplePosition *samplePositions);
- void drawInstanced(
+ public void drawInstanced(
GfxCount vertexCount,
GfxCount instanceCount,
GfxIndex startVertex,
GfxIndex startInstanceLocation);
- void drawIndexedInstanced(
+ public void drawIndexedInstanced(
GfxCount indexCount,
GfxCount instanceCount,
GfxIndex startIndexLocation,
@@ -1466,62 +1466,62 @@ interface IRenderCommandEncoder : IResourceCommandEncoder
};
[COM("88AA9322-82F7-4FE6-A68A-29C7FE798737")]
-interface IComputeCommandEncoder : IResourceCommandEncoder
+public interface IComputeCommandEncoder : IResourceCommandEncoder
{
// Sets the current pipeline state. This method returns a transient shader object for
// writing shader parameters. This shader object will not retain any resources or
// sub-shader-objects bound to it. The user must be responsible for ensuring that any
// resources or shader objects that is set into `outRooShaderObject` stays alive during
// the execution of the command buffer.
- Result bindPipeline(IPipelineState state, out Optional<IShaderObject> outRootShaderObject);
-
+ public Result bindPipeline(IPipelineState state, out Optional<IShaderObject> outRootShaderObject);
+
// Sets the current pipeline state along with a pre-created mutable root shader object.
- Result bindPipelineWithRootObject(IPipelineState state, IShaderObject rootObject);
+ public Result bindPipelineWithRootObject(IPipelineState state, IShaderObject rootObject);
- void dispatchCompute(int x, int y, int z);
- void dispatchComputeIndirect(IBufferResource cmdBuffer, Offset offset);
+ public void dispatchCompute(int x, int y, int z);
+ public void dispatchComputeIndirect(IBufferResource cmdBuffer, Offset offset);
};
-enum class AccelerationStructureCopyMode
+public enum class AccelerationStructureCopyMode
{
Clone, Compact
};
-struct AccelerationStructureQueryDesc
+public struct AccelerationStructureQueryDesc
{
- QueryType queryType;
+ public QueryType queryType;
- NativeRef<IQueryPool> queryPool;
+ public NativeRef<IQueryPool> queryPool;
- GfxIndex firstQueryIndex;
+ public GfxIndex firstQueryIndex;
};
[COM("9a672b87-5035-45e3-967c-1f-85-cd-b3-63-4f")]
-interface IRayTracingCommandEncoder : IResourceCommandEncoder
+public interface IRayTracingCommandEncoder : IResourceCommandEncoder
{
- void buildAccelerationStructure(
- AccelerationStructureBuildDesc *desc,
- GfxCount propertyQueryCount,
- AccelerationStructureQueryDesc *queryDescs);
- void copyAccelerationStructure(
+ public void buildAccelerationStructure(
+ AccelerationStructureBuildDesc *desc,
+ GfxCount propertyQueryCount,
+ AccelerationStructureQueryDesc *queryDescs);
+ public void copyAccelerationStructure(
NativeRef<IAccelerationStructure> dest,
NativeRef<IAccelerationStructure> src,
AccelerationStructureCopyMode mode);
- void queryAccelerationStructureProperties(
+ public void queryAccelerationStructureProperties(
GfxCount accelerationStructureCount,
NativeRef<IAccelerationStructure> *accelerationStructures,
GfxCount queryCount,
AccelerationStructureQueryDesc *queryDescs);
- void serializeAccelerationStructure(DeviceAddress dest, IAccelerationStructure source);
- void deserializeAccelerationStructure(IAccelerationStructure dest, DeviceAddress source);
+ public void serializeAccelerationStructure(DeviceAddress dest, IAccelerationStructure source);
+ public void deserializeAccelerationStructure(IAccelerationStructure dest, DeviceAddress source);
- void bindPipeline(IPipelineState state, out IShaderObject rootObject);
+ public void bindPipeline(IPipelineState state, out IShaderObject rootObject);
// Sets the current pipeline state along with a pre-created mutable root shader object.
- Result bindPipelineWithRootObject(IPipelineState state, IShaderObject rootObject);
+ public Result bindPipelineWithRootObject(IPipelineState state, IShaderObject rootObject);
/// Issues a dispatch command to start ray tracing workload with a ray tracing pipeline.
/// `rayGenShaderIndex` specifies the index into the shader table that identifies the ray generation shader.
- void dispatchRays(
+ public void dispatchRays(
GfxIndex rayGenShaderIndex,
NativeRef<IShaderTable> shaderTable,
GfxCount width,
@@ -1530,241 +1530,241 @@ interface IRayTracingCommandEncoder : IResourceCommandEncoder
};
[COM("5d56063f-91d4-4723-a7a7-7a-15-af-93-eb-48")]
-interface ICommandBuffer
+public interface ICommandBuffer
{
// Only one encoder may be open at a time. User must call `ICommandEncoder::endEncoding`
// before calling other `encode*Commands` methods.
// Once `endEncoding` is called, the `ICommandEncoder` object becomes obsolete and is
// invalid for further use. To continue recording, the user must request a new encoder
// object by calling one of the `encode*Commands` methods again.
- void encodeRenderCommands(
+ public void encodeRenderCommands(
IRenderPassLayout renderPass,
IFramebuffer framebuffer,
out IRenderCommandEncoder outEncoder);
- void encodeComputeCommands(out Optional<IComputeCommandEncoder> encoder);
+ public void encodeComputeCommands(out Optional<IComputeCommandEncoder> encoder);
- void encodeResourceCommands(out Optional<IResourceCommandEncoder> outEncoder);
+ public void encodeResourceCommands(out Optional<IResourceCommandEncoder> outEncoder);
- void encodeRayTracingCommands(out Optional<IRayTracingCommandEncoder> outEncoder);
+ public void encodeRayTracingCommands(out Optional<IRayTracingCommandEncoder> outEncoder);
- void close();
+ public void close();
- Result getNativeHandle(out InteropHandle outHandle);
+ public Result getNativeHandle(out InteropHandle outHandle);
};
-enum class QueueType
+public enum class QueueType
{
Graphics
};
-struct CommandQueueDesc
+public struct CommandQueueDesc
{
- QueueType type;
+ public QueueType type;
};
[COM("14e2bed0-0ad0-4dc8-b341-06-3f-e7-2d-bf-0e")]
-interface ICommandQueue
+public interface ICommandQueue
{
- const CommandQueueDesc* getDesc();
+ public const CommandQueueDesc* getDesc();
- void executeCommandBuffers(
+ public void executeCommandBuffers(
GfxCount count,
NativeRef<ICommandBuffer> *commandBuffers,
Optional<IFence> fenceToSignal,
uint64_t newFenceValue);
- Result getNativeHandle(out InteropHandle outHandle);
+ public Result getNativeHandle(out InteropHandle outHandle);
- void waitOnHost();
+ public void waitOnHost();
/// Queues a device side wait for the given fences.
- Result waitForFenceValuesOnDevice(GfxCount fenceCount, NativeRef<IFence> *fences, uint64_t *waitValues);
+ public Result waitForFenceValuesOnDevice(GfxCount fenceCount, NativeRef<IFence> *fences, uint64_t *waitValues);
};
-enum TransientResourceHeapFlags
+public enum TransientResourceHeapFlags
{
None = 0,
AllowResizing = 0x1,
};
-struct TransientResourceHeapDesc
+public struct TransientResourceHeapDesc
{
- TransientResourceHeapFlags flags;
- Size constantBufferSize;
- GfxCount samplerDescriptorCount;
- GfxCount uavDescriptorCount;
- GfxCount srvDescriptorCount;
- GfxCount constantBufferDescriptorCount;
- GfxCount accelerationStructureDescriptorCount;
+ public TransientResourceHeapFlags flags;
+ public Size constantBufferSize;
+ public GfxCount samplerDescriptorCount;
+ public GfxCount uavDescriptorCount;
+ public GfxCount srvDescriptorCount;
+ public GfxCount constantBufferDescriptorCount;
+ public GfxCount accelerationStructureDescriptorCount;
};
[COM("cd48bd29-ee72-41b8-bcff-0a-2b-3a-aa-6d-0b")]
-interface ITransientResourceHeap
+public interface ITransientResourceHeap
{
// Waits until GPU commands issued before last call to `finish()` has been completed, and resets
// all transient resources holds by the heap.
// This method must be called before using the transient heap to issue new GPU commands.
// In most situations this method should be called at the beginning of each frame.
- Result synchronizeAndReset();
+ public Result synchronizeAndReset();
// Must be called when the application has done using this heap to issue commands. In most situations
// this method should be called at the end of each frame.
- Result finish();
+ public Result finish();
// Command buffers are one-time use. Once it is submitted to the queue via
// `executeCommandBuffers` a command buffer is no longer valid to be used any more. Command
// buffers must be closed before submission. The current D3D12 implementation has a limitation
// that only one command buffer maybe recorded at a time. User must finish recording a command
// buffer before creating another command buffer.
- Result createCommandBuffer(out Optional<ICommandBuffer> outCommandBuffer);
+ public Result createCommandBuffer(out Optional<ICommandBuffer> outCommandBuffer);
};
-struct SwapchainDesc
+public struct SwapchainDesc
{
- Format format;
- GfxCount width, height;
- GfxCount imageCount;
- NativeRef<ICommandQueue> queue;
- bool enableVSync;
+ public Format format;
+ public GfxCount width, height;
+ public GfxCount imageCount;
+ public NativeRef<ICommandQueue> queue;
+ public bool enableVSync;
};
[COM("be91ba6c-0784-4308-a1-00-19-c3-66-83-44-b2")]
-interface ISwapchain
+public interface ISwapchain
{
- const SwapchainDesc* getDesc();
+ public const SwapchainDesc* getDesc();
/// Returns the back buffer image at `index`.
- Result getImage(GfxIndex index, out ITextureResource outResource);
+ public Result getImage(GfxIndex index, out ITextureResource outResource);
/// Present the next image in the swapchain.
- Result present();
+ public Result present();
/// Returns the index of next back buffer image that will be presented in the next
/// `present` call. If the swapchain is invalid/out-of-date, this method returns -1.
- int acquireNextImage();
+ public int acquireNextImage();
/// Resizes the back buffers of this swapchain. All render target views and framebuffers
/// referencing the back buffer images must be freed before calling this method.
- Result resize(GfxCount width, GfxCount height);
+ public Result resize(GfxCount width, GfxCount height);
// Check if the window is occluded.
- bool isOccluded();
+ public bool isOccluded();
// Toggle full screen mode.
- Result setFullScreenMode(bool mode);
+ public Result setFullScreenMode(bool mode);
};
-struct DeviceInfo
+public struct DeviceInfo
{
- DeviceType deviceType;
+ public DeviceType deviceType;
- BindingStyle bindingStyle;
+ public BindingStyle bindingStyle;
- ProjectionStyle projectionStyle;
+ public ProjectionStyle projectionStyle;
/// An projection matrix that ensures x, y mapping to pixels
/// is the same on all targets
- float identityProjectionMatrix[16];
+ public float identityProjectionMatrix[16];
/// The name of the graphics API being used by this device.
- NativeString apiName;
+ public NativeString apiName;
/// The name of the graphics adapter.
- NativeString adapterName;
+ public NativeString adapterName;
/// The clock frequency used in timestamp queries.
- uint64_t timestampFrequency;
+ public uint64_t timestampFrequency;
};
-enum class DebugMessageType
+public enum class DebugMessageType
{
Info, Warning, Error
};
-enum class DebugMessageSource
+public enum class DebugMessageSource
{
Layer, Driver, Slang
};
[COM("B219D7E8-255A-2572-D46C-A0E5D99CEB90")]
-interface IDebugCallback
+public interface IDebugCallback
{
- void handleMessage(DebugMessageType type, DebugMessageSource source, NativeString message);
+ public void handleMessage(DebugMessageType type, DebugMessageSource source, NativeString message);
};
-struct SlangDesc
+public struct SlangDesc
{
- NativeRef<slang::IGlobalSession> slangGlobalSession; // (optional) A slang global session object. If null will create automatically.
+ public NativeRef<slang::IGlobalSession> slangGlobalSession; // (optional) A slang global session object. If null will create automatically.
- slang::SlangMatrixLayoutMode defaultMatrixLayoutMode = slang::SlangMatrixLayoutMode::SLANG_MATRIX_LAYOUT_ROW_MAJOR;
+ public slang::SlangMatrixLayoutMode defaultMatrixLayoutMode = slang::SlangMatrixLayoutMode::SLANG_MATRIX_LAYOUT_ROW_MAJOR;
- NativeString *searchPaths;
- GfxCount searchPathCount;
+ public NativeString *searchPaths;
+ public GfxCount searchPathCount;
- slang::PreprocessorMacroDesc* preprocessorMacros;
- GfxCount preprocessorMacroCount = 0;
+ public slang::PreprocessorMacroDesc *preprocessorMacros;
+ public GfxCount preprocessorMacroCount = 0;
- NativeString targetProfile; // (optional) Target shader profile. If null this will be set to platform dependent default.
- slang::SlangFloatingPointMode floatingPointMode = slang::SlangFloatingPointMode::SLANG_FLOATING_POINT_MODE_DEFAULT;
- slang::SlangOptimizationLevel optimizationLevel = slang::SlangOptimizationLevel::SLANG_OPTIMIZATION_LEVEL_DEFAULT;
- slang::SlangTargetFlags targetFlags = slang::SlangTargetFlags.None;
- slang::SlangLineDirectiveMode lineDirectiveMode = slang::SlangLineDirectiveMode::SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
+ public NativeString targetProfile; // (optional) Target shader profile. If null this will be set to platform dependent default.
+ public slang::SlangFloatingPointMode floatingPointMode = slang::SlangFloatingPointMode::SLANG_FLOATING_POINT_MODE_DEFAULT;
+ public slang::SlangOptimizationLevel optimizationLevel = slang::SlangOptimizationLevel::SLANG_OPTIMIZATION_LEVEL_DEFAULT;
+ public slang::SlangTargetFlags targetFlags = slang::SlangTargetFlags.None;
+ public slang::SlangLineDirectiveMode lineDirectiveMode = slang::SlangLineDirectiveMode::SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
};
-struct ShaderCacheDesc
+public struct ShaderCacheDesc
{
// The root directory for the shader cache. If not set, shader cache is disabled.
- NativeString shaderCachePath;
+ public NativeString shaderCachePath;
// The maximum number of entries stored in the cache.
- GfxCount maxEntryCount = 0;
+ public GfxCount maxEntryCount = 0;
};
-struct DeviceInteropHandles
+public struct DeviceInteropHandles
{
- InteropHandle handles[3] = {};
+ public InteropHandle handles[3] = {};
};
-struct DeviceDesc
+public struct DeviceDesc
{
// The underlying API/Platform of the device.
- DeviceType deviceType = DeviceType::Default;
+ public DeviceType deviceType = DeviceType::Default;
// The device's handles (if they exist) and their associated API. For D3D12, this contains a single InteropHandle
// for the ID3D12Device. For Vulkan, the first InteropHandle is the VkInstance, the second is the VkPhysicalDevice,
// and the third is the VkDevice. For CUDA, this only contains a single value for the CUDADevice.
- DeviceInteropHandles existingDeviceHandles;
+ public DeviceInteropHandles existingDeviceHandles;
// Name to identify the adapter to use
- NativeString adapter;
+ public NativeString adapter;
// Number of required features.
- GfxCount requiredFeatureCount = 0;
+ public GfxCount requiredFeatureCount = 0;
// Array of required feature names, whose size is `requiredFeatureCount`.
- NativeString *requiredFeatures = nullptr;
+ public NativeString *requiredFeatures = nullptr;
// A command dispatcher object that intercepts and handles actual low-level API call.
void *apiCommandDispatcher = nullptr;
// The slot (typically UAV) used to identify NVAPI intrinsics. If >=0 NVAPI is required.
- GfxIndex nvapiExtnSlot = -1;
+ public GfxIndex nvapiExtnSlot = -1;
// Configurations for the shader cache.
- ShaderCacheDesc shaderCache = {};
+ public ShaderCacheDesc shaderCache = {};
// Configurations for Slang compiler.
- SlangDesc slang = {};
+ public SlangDesc slang = {};
- GfxCount extendedDescCount = 0;
- void **extendedDescs = nullptr;
+ public GfxCount extendedDescCount = 0;
+ public void **extendedDescs = nullptr;
};
[COM("715bdf26-5135-11eb-AE93-02-42-AC-13-00-02")]
-interface IDevice
+public interface IDevice
{
- Result getNativeDeviceHandles(out DeviceInteropHandles outHandles);
+ public Result getNativeDeviceHandles(out DeviceInteropHandles outHandles);
- bool hasFeature(NativeString feature);
+ public bool hasFeature(NativeString feature);
/// Returns a list of features supported by the renderer.
- Result getFeatures(NativeString *outFeatures, Size bufferSize, GfxCount *outFeatureCount);
+ public Result getFeatures(NativeString *outFeatures, Size bufferSize, GfxCount *outFeatureCount);
- Result getFormatSupportedResourceStates(Format format, ResourceStateSet *outStates);
+ public Result getFormatSupportedResourceStates(Format format, ResourceStateSet *outStates);
- Result getSlangSession(NativeRef<slang::ISession>* outSlangSession);
+ public Result getSlangSession(NativeRef<slang::ISession>* outSlangSession);
- Result createTransientResourceHeap(
+ public Result createTransientResourceHeap(
TransientResourceHeapDesc *desc,
out Optional<ITransientResourceHeap> outHeap);
@@ -1782,194 +1782,194 @@ interface IDevice
///
/// effectiveElementCount = (isArray ? arrayElementCount : 1) * (isCube ? 6 : 1);
///
- Result createTextureResource(
+ public Result createTextureResource(
TextureResourceDesc* desc,
SubresourceData *initData,
out ITextureResource outResource);
- Result createTextureFromNativeHandle(
+ public Result createTextureFromNativeHandle(
InteropHandle handle,
TextureResourceDesc* srcDesc,
out ITextureResource outResource);
- Result createTextureFromSharedHandle(
+ public Result createTextureFromSharedHandle(
InteropHandle handle,
TextureResourceDesc *srcDesc,
Size size,
out ITextureResource outResource);
/// Create a buffer resource
- Result createBufferResource(
+ public Result createBufferResource(
BufferResourceDesc* desc,
void *initData,
out Optional<IBufferResource> outResource);
- Result createBufferFromNativeHandle(
+ public Result createBufferFromNativeHandle(
InteropHandle handle,
BufferResourceDesc* srcDesc,
out IBufferResource outResource);
- Result createBufferFromSharedHandle(
+ public Result createBufferFromSharedHandle(
InteropHandle handle,
BufferResourceDesc* srcDesc,
out IBufferResource outResource);
- Result createSamplerState(SamplerStateDesc* desc, out ISamplerState outSampler);
+ public Result createSamplerState(SamplerStateDesc* desc, out ISamplerState outSampler);
- Result createTextureView(
+ public Result createTextureView(
ITextureResource texture, ResourceViewDesc* desc, out IResourceView outView);
- Result createBufferView(
+ public Result createBufferView(
IBufferResource buffer,
Optional<IBufferResource> counterBuffer,
ResourceViewDesc* desc,
out Optional<IResourceView> outView);
- Result createFramebufferLayout(FramebufferLayoutDesc* desc, out IFramebufferLayout outFrameBuffer);
-
- Result createFramebuffer(FramebufferDesc* desc, out IFramebuffer outFrameBuffer);
+ public Result createFramebufferLayout(FramebufferLayoutDesc* desc, out IFramebufferLayout outFrameBuffer);
+
+ public Result createFramebuffer(FramebufferDesc* desc, out IFramebuffer outFrameBuffer);
- Result createRenderPassLayout(
+ public Result createRenderPassLayout(
RenderPassLayoutDesc* desc,
out IRenderPassLayout outRenderPassLayout);
- Result createSwapchain(
+ public Result createSwapchain(
SwapchainDesc* desc, WindowHandle window, out ISwapchain outSwapchain);
- Result createInputLayout(
+ public Result createInputLayout(
InputLayoutDesc* desc, out IInputLayout outLayout);
- Result createCommandQueue(CommandQueueDesc* desc, out Optional<ICommandQueue> outQueue);
+ public Result createCommandQueue(CommandQueueDesc* desc, out Optional<ICommandQueue> outQueue);
- Result createShaderObject(
+ public Result createShaderObject(
slang::TypeReflection *type,
ShaderObjectContainerType container,
out IShaderObject outObject);
- Result createMutableShaderObject(
+ public Result createMutableShaderObject(
slang::TypeReflection *type,
ShaderObjectContainerType container,
out IShaderObject outObject);
- Result createShaderObjectFromTypeLayout(
+ public Result createShaderObjectFromTypeLayout(
slang::TypeLayoutReflection *typeLayout, out IShaderObject outObject);
- Result createMutableShaderObjectFromTypeLayout(
+ public Result createMutableShaderObjectFromTypeLayout(
slang::TypeLayoutReflection *typeLayout, out IShaderObject outObject);
- Result createMutableRootShaderObject(
+ public Result createMutableRootShaderObject(
IShaderProgram program,
out IShaderObject outObject);
- Result createShaderTable(ShaderTableDesc* desc, out IShaderTable outTable);
+ public Result createShaderTable(ShaderTableDesc* desc, out IShaderTable outTable);
- Result createProgram(
+ public Result createProgram(
void *desc,
out IShaderProgram outProgram,
out slang::ISlangBlob outDiagnosticBlob);
- Result createProgram2(
+ public Result createProgram2(
ShaderProgramDesc2 *desc,
out Optional<IShaderProgram> outProgram,
out Optional<slang::ISlangBlob> outDiagnosticBlob);
- Result createGraphicsPipelineState(
+ public Result createGraphicsPipelineState(
GraphicsPipelineStateDesc *desc,
out Optional<IPipelineState> outState);
- Result createComputePipelineState(
+ public Result createComputePipelineState(
ComputePipelineStateDesc* desc,
out Optional<IPipelineState> outState);
- Result createRayTracingPipelineState(
+ public Result createRayTracingPipelineState(
RayTracingPipelineStateDesc *desc, out Optional<IPipelineState> outState);
/// Read back texture resource and stores the result in `outBlob`.
- Result readTextureResource(
+ public Result readTextureResource(
ITextureResource resource,
ResourceState state,
out slang::ISlangBlob outBlob,
out Size outRowPitch,
out Size outPixelSize);
- Result readBufferResource(
+ public Result readBufferResource(
IBufferResource buffer,
Offset offset,
Size size,
out Optional<slang::ISlangBlob> outBlob);
/// Get the type of this renderer
- DeviceInfo* getDeviceInfo();
+ public DeviceInfo* getDeviceInfo();
- Result createQueryPool(
+ public Result createQueryPool(
QueryPoolDesc* desc, out IQueryPool outPool);
- Result getAccelerationStructurePrebuildInfo(
+ public Result getAccelerationStructurePrebuildInfo(
AccelerationStructureBuildInputs* buildInputs,
out AccelerationStructurePrebuildInfo outPrebuildInfo);
- Result createAccelerationStructure(
+ public Result createAccelerationStructure(
AccelerationStructureCreateDesc* desc,
out IAccelerationStructure outView);
- Result createFence(FenceDesc* desc, out IFence outFence);
+ public Result createFence(FenceDesc* desc, out IFence outFence);
/// Wait on the host for the fences to signals.
/// `timeout` is in nanoseconds, can be set to `kTimeoutInfinite`.
- Result waitForFences(
+ public Result waitForFences(
GfxCount fenceCount,
NativeRef<IFence>* fences,
uint64_t *values,
bool waitForAll,
uint64_t timeout);
- Result getTextureAllocationInfo(
+ public Result getTextureAllocationInfo(
TextureResourceDesc* desc, out Size outSize, out Size outAlignment);
- Result getTextureRowAlignment(out Size outAlignment);
+ public Result getTextureRowAlignment(out Size outAlignment);
};
-struct ShaderCacheStats
+public struct ShaderCacheStats
{
- GfxCount hitCount;
- GfxCount missCount;
- GfxCount entryCount;
+ public GfxCount hitCount;
+ public GfxCount missCount;
+ public GfxCount entryCount;
};
[COM("715bdf26-5135-11eb-AE93-02-42-AC-13-00-02")]
-interface IShaderCache
+public interface IShaderCache
{
- Result clearShaderCache();
- Result getShaderCacheStats(out ShaderCacheStats outStats);
- Result resetShaderCacheStats();
+ public Result clearShaderCache();
+ public Result getShaderCacheStats(out ShaderCacheStats outStats);
+ public Result resetShaderCacheStats();
};
#define SLANG_GFX_IMPORT [DllImport("gfx")]
/// Checks if format is compressed
-SLANG_GFX_IMPORT bool gfxIsCompressedFormat(Format format);
+SLANG_GFX_IMPORT public bool gfxIsCompressedFormat(Format format);
/// Checks if format is typeless
-SLANG_GFX_IMPORT bool gfxIsTypelessFormat(Format format);
+SLANG_GFX_IMPORT public bool gfxIsTypelessFormat(Format format);
/// Gets information about the format
-SLANG_GFX_IMPORT Result gfxGetFormatInfo(Format format, FormatInfo *outInfo);
+SLANG_GFX_IMPORT public Result gfxGetFormatInfo(Format format, FormatInfo *outInfo);
-/// Given a type returns a function that can construct it, or nullptr if there isn't one
-SLANG_GFX_IMPORT Result gfxCreateDevice(const DeviceDesc* desc, out Optional<IDevice> outDevice);
+/// Given a type returns a function that can conpublic struct it, or nullptr if there isn't one
+SLANG_GFX_IMPORT public Result gfxCreateDevice(const DeviceDesc* desc, out Optional<IDevice> outDevice);
/// Reports current set of live objects in gfx.
/// Currently this only calls D3D's ReportLiveObjects.
-SLANG_GFX_IMPORT Result gfxReportLiveObjects();
+SLANG_GFX_IMPORT public Result gfxReportLiveObjects();
/// Sets a callback for receiving debug messages.
/// The layer does not hold a strong reference to the callback object.
/// The user is responsible for holding the callback object alive.
-SLANG_GFX_IMPORT Result gfxSetDebugCallback(IDebugCallback callback);
+SLANG_GFX_IMPORT public Result gfxSetDebugCallback(IDebugCallback callback);
/// Enables debug layer. The debug layer will check all `gfx` calls and verify that uses are valid.
-SLANG_GFX_IMPORT void gfxEnableDebugLayer();
+SLANG_GFX_IMPORT public void gfxEnableDebugLayer();
-SLANG_GFX_IMPORT NativeString gfxGetDeviceTypeName(DeviceType type);
+SLANG_GFX_IMPORT public NativeString gfxGetDeviceTypeName(DeviceType type);
public bool succeeded(Result code)
{
diff --git a/tools/gfx/slang.slang b/tools/gfx/slang.slang
index aa28fae82..4e2700c2c 100644
--- a/tools/gfx/slang.slang
+++ b/tools/gfx/slang.slang
@@ -1,10 +1,10 @@
-namespace slang
+public namespace slang
{
-typedef int32_t Result;
-typedef uint64_t Size;
-typedef int64_t Int;
-typedef uint64_t UInt;
+public typedef int32_t Result;
+public typedef uint64_t Size;
+public typedef int64_t Int;
+public typedef uint64_t UInt;
/*!
@brief Severity of a diagnostic generated by the compiler.
@@ -12,7 +12,7 @@ Values come from the enum below, with higher values representing more severe
conditions, and all values >= SLANG_SEVERITY_ERROR indicating compilation
failure.
*/
-enum SlangSeverity
+public enum SlangSeverity
{
SLANG_SEVERITY_DISABLED = 0, /**< A message that is disabled, filtered out. */
SLANG_SEVERITY_NOTE, /**< An informative message. */
@@ -22,13 +22,13 @@ enum SlangSeverity
SLANG_SEVERITY_INTERNAL, /**< An internal error, indicating a logic error in the compiler. */
};
-enum SlangDiagnosticFlags
+public enum SlangDiagnosticFlags
{
SLANG_DIAGNOSTIC_FLAG_VERBOSE_PATHS = 0x01,
SLANG_DIAGNOSTIC_FLAG_TREAT_WARNINGS_AS_ERRORS = 0x02
};
-enum SlangBindableResourceType
+public enum SlangBindableResourceType
{
SLANG_NON_BINDABLE = 0,
SLANG_TEXTURE,
@@ -37,7 +37,7 @@ enum SlangBindableResourceType
SLANG_STORAGE_BUFFER,
};
-enum SlangCompileTarget
+public enum SlangCompileTarget
{
SLANG_TARGET_UNKNOWN,
SLANG_TARGET_NONE,
@@ -68,7 +68,7 @@ enum SlangCompileTarget
/* A "container format" describes the way that the outputs
for multiple files, entry points, targets, etc. should be
combined into a single artifact for output. */
-enum SlangContainerFormat
+public enum SlangContainerFormat
{
/* Don't generate a container. */
SLANG_CONTAINER_FORMAT_NONE,
@@ -78,7 +78,7 @@ enum SlangContainerFormat
SLANG_CONTAINER_FORMAT_SLANG_MODULE,
};
-enum SlangPassThrough : int
+public enum SlangPassThrough : int
{
SLANG_PASS_THROUGH_NONE,
SLANG_PASS_THROUGH_FXC,
@@ -96,7 +96,7 @@ enum SlangPassThrough : int
};
/* Defines an archive type used to holds a 'file system' type structure. */
-enum SlangArchiveType : int
+public enum SlangArchiveType : int
{
SLANG_ARCHIVE_TYPE_UNDEFINED,
SLANG_ARCHIVE_TYPE_ZIP,
@@ -109,7 +109,7 @@ enum SlangArchiveType : int
/*!
Flags to control compilation behavior.
*/
-enum SlangCompileFlags
+public enum SlangCompileFlags
{
/* Do as little mangling of names as possible, to try to preserve original names */
SLANG_COMPILE_FLAG_NO_MANGLING = 1 << 3,
@@ -129,7 +129,7 @@ enum SlangCompileFlags
/*!
@brief Flags to control code generation behavior of a compilation target */
-enum SlangTargetFlags
+public enum SlangTargetFlags
{
None = 0,
@@ -156,7 +156,7 @@ enum SlangTargetFlags
/*!
@brief Options to control floating-point precision guarantees for a target.
*/
-enum SlangFloatingPointMode
+public enum SlangFloatingPointMode
{
SLANG_FLOATING_POINT_MODE_DEFAULT = 0,
SLANG_FLOATING_POINT_MODE_FAST,
@@ -166,7 +166,7 @@ enum SlangFloatingPointMode
/*!
@brief Options to control emission of `#line` directives
*/
-enum SlangLineDirectiveMode
+public enum SlangLineDirectiveMode
{
SLANG_LINE_DIRECTIVE_MODE_DEFAULT = 0, /**< Default behavior: pick behavior base on target. */
SLANG_LINE_DIRECTIVE_MODE_NONE, /**< Don't emit line directives at all. */
@@ -174,7 +174,7 @@ enum SlangLineDirectiveMode
SLANG_LINE_DIRECTIVE_MODE_GLSL, /**< Emit GLSL-style directives with file *number* instead of name */
};
-enum SlangSourceLanguage : int
+public enum SlangSourceLanguage : int
{
SLANG_SOURCE_LANGUAGE_UNKNOWN,
SLANG_SOURCE_LANGUAGE_SLANG,
@@ -186,24 +186,24 @@ enum SlangSourceLanguage : int
SLANG_SOURCE_LANGUAGE_COUNT_OF,
};
-enum SlangProfileID
+public enum SlangProfileID
{
SLANG_PROFILE_UNKNOWN,
};
-enum SlangCapabilityID
+public enum SlangCapabilityID
{
SLANG_CAPABILITY_UNKNOWN = 0,
};
-enum SlangMatrixLayoutMode
+public enum SlangMatrixLayoutMode
{
SLANG_MATRIX_LAYOUT_MODE_UNKNOWN = 0,
SLANG_MATRIX_LAYOUT_ROW_MAJOR,
SLANG_MATRIX_LAYOUT_COLUMN_MAJOR,
};
-enum SlangStage
+public enum SlangStage
{
SLANG_STAGE_NONE,
SLANG_STAGE_VERTEX,
@@ -222,7 +222,7 @@ enum SlangStage
SLANG_STAGE_AMPLIFICATION,
};
-enum SlangDebugInfoLevel
+public enum SlangDebugInfoLevel
{
SLANG_DEBUG_INFO_LEVEL_NONE = 0, /**< Don't emit debug information at all. */
SLANG_DEBUG_INFO_LEVEL_MINIMAL, /**< Emit as little debug information as possible, while still supporting stack trackes. */
@@ -230,14 +230,14 @@ enum SlangDebugInfoLevel
SLANG_DEBUG_INFO_LEVEL_MAXIMAL, /**< Emit as much debug infromation as possible for each target. */
};
-enum SlangOptimizationLevel
+public enum SlangOptimizationLevel
{
SLANG_OPTIMIZATION_LEVEL_NONE = 0, /**< Don't optimize at all. */
SLANG_OPTIMIZATION_LEVEL_DEFAULT, /**< Default optimization level: balance code quality and compilation time. */
SLANG_OPTIMIZATION_LEVEL_HIGH, /**< Optimize aggressively. */
SLANG_OPTIMIZATION_LEVEL_MAXIMAL, /**< Include optimizations that may take a very long time, or may involve severe space-vs-speed tradeoffs */
};
-enum SlangTypeKind
+public enum SlangTypeKind
{
NONE,
STRUCT,
@@ -259,7 +259,7 @@ enum SlangTypeKind
COUNT,
};
-enum SlangScalarType
+public enum SlangScalarType
{
NONE,
VOID,
@@ -277,59 +277,59 @@ enum SlangScalarType
UINT16,
};
-struct TypeReflection
+public struct TypeReflection
{
};
-enum CompileStdLibFlags
+public enum CompileStdLibFlags
{
WriteDocumentation = 0x1,
};
[COM("8BA5FB08-5195-40e2-AC58-0D-98-9C-3A-01-02")]
-interface ISlangBlob
+public interface ISlangBlob
{
- void *getBufferPointer();
- Size getBufferSize();
+ public void *getBufferPointer();
+ public Size getBufferSize();
};
/** Description of a code generation target.
*/
-struct TargetDesc
+public struct TargetDesc
{
/** The size of this structure, in bytes.
*/
- Size structureSize = 40;
+ public Size structureSize = 40;
/** The target format to generate code for (e.g., SPIR-V, DXIL, etc.)
*/
- SlangCompileTarget format = SlangCompileTarget.SLANG_TARGET_UNKNOWN;
+ public SlangCompileTarget format = SlangCompileTarget.SLANG_TARGET_UNKNOWN;
/** The compilation profile supported by the target (e.g., "Shader Model 5.1")
*/
- SlangProfileID profile = SlangProfileID.SLANG_PROFILE_UNKNOWN;
+ public SlangProfileID profile = SlangProfileID.SLANG_PROFILE_UNKNOWN;
/** Flags for the code generation target. Currently unused. */
- SlangTargetFlags flags = SlangTargetFlags.None;
+ public SlangTargetFlags flags = SlangTargetFlags.None;
/** Default mode to use for floating-point operations on the target.
*/
- SlangFloatingPointMode floatingPointMode = SlangFloatingPointMode.SLANG_FLOATING_POINT_MODE_DEFAULT;
+ public SlangFloatingPointMode floatingPointMode = SlangFloatingPointMode.SLANG_FLOATING_POINT_MODE_DEFAULT;
/** Optimization level to use for the target.
*/
- SlangOptimizationLevel optimizationLevel = SlangOptimizationLevel.SLANG_OPTIMIZATION_LEVEL_DEFAULT;
+ public SlangOptimizationLevel optimizationLevel = SlangOptimizationLevel.SLANG_OPTIMIZATION_LEVEL_DEFAULT;
/** The line directive mode for output source code.
*/
- SlangLineDirectiveMode lineDirectiveMode = SlangLineDirectiveMode.SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
+ public SlangLineDirectiveMode lineDirectiveMode = SlangLineDirectiveMode.SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
/** Whether to force `scalar` layout for glsl shader storage buffers.
*/
- bool forceGLSLScalarBufferLayout = false;
+ public bool forceGLSLScalarBufferLayout = false;
};
-enum SessionFlags
+public enum SessionFlags
{
kSessionFlags_None = 0,
@@ -344,40 +344,40 @@ enum SessionFlags
kSessionFlag_FalcorCustomSharedKeywordSemantics = 1 << 0,
};
-struct PreprocessorMacroDesc
+public struct PreprocessorMacroDesc
{
- NativeString name;
- NativeString value;
+ public NativeString name;
+ public NativeString value;
};
-struct SessionDesc
+public struct SessionDesc
{
/** The size of this structure, in bytes.
*/
- Size structureSize = 72;
+ public Size structureSize = 72;
/** Code generation targets to include in the session.
*/
- TargetDesc *targets = nullptr;
- Int targetCount = 0;
+ public TargetDesc *targets = nullptr;
+ public Int targetCount = 0;
/** Flags to configure the session.
*/
- SessionFlags flags = SessionFlags.kSessionFlags_None;
+ public SessionFlags flags = SessionFlags.kSessionFlags_None;
/** Default layout to assume for variables with matrix types.
*/
- SlangMatrixLayoutMode defaultMatrixLayoutMode = SlangMatrixLayoutMode.SLANG_MATRIX_LAYOUT_ROW_MAJOR;
+ public SlangMatrixLayoutMode defaultMatrixLayoutMode = SlangMatrixLayoutMode.SLANG_MATRIX_LAYOUT_ROW_MAJOR;
/** Paths to use when searching for `#include`d or `import`ed files.
*/
- NativeString *searchPaths = nullptr;
- Int searchPathCount = 0;
+ public NativeString *searchPaths = nullptr;
+ public Int searchPathCount = 0;
- PreprocessorMacroDesc *preprocessorMacros = nullptr;
- Int preprocessorMacroCount = 0;
+ public PreprocessorMacroDesc *preprocessorMacros = nullptr;
+ public Int preprocessorMacroCount = 0;
- void *fileSystem = nullptr;
+ public void *fileSystem = nullptr;
};
/** A global session for interaction with the Slang library.
@@ -391,11 +391,11 @@ a single global session should only be used from a single thread at
a time.
*/
[COM("c140b5fd-0c78-452e-ba7c-1a-1e-70-c7-f7-1c")]
-interface IGlobalSession
+public interface IGlobalSession
{
};
-enum class ContainerType
+public enum class ContainerType
{
None, UnsizedArray, StructuredBuffer, ConstantBuffer, ParameterBlock
};
@@ -426,29 +426,29 @@ Applications wishing to control the memory usage for compiled
and loaded code should use multiple sessions.
*/
[COM("67618701-d116-468f-ab3b-47-4b-ed-ce-0e-3d")]
-interface ISession
+public interface ISession
{
};
[COM("5bc42be8-5c50-4929-9e5e-d15e7c24015f")]
-interface IComponentType
+public interface IComponentType
{
}
-struct TypeLayoutReflection { }
+public struct TypeLayoutReflection { }
/** The kind of specialization argument. */
-enum class SpecializationArgKind : int32_t
+public enum class SpecializationArgKind : int32_t
{
Unknown, /**< An invalid specialization argument. */
Type, /**< Specialize to a type. */
};
-struct SpecializationArg
+public struct SpecializationArg
{
- SpecializationArgKind kind;
+ public SpecializationArgKind kind;
/** A type specialization argument, used for `Kind::Type`. */
- TypeReflection *type;
+ public TypeReflection *type;
}
}
diff --git a/tools/slang-unit-test/unit-test-com-host-callable.slang b/tools/slang-unit-test/unit-test-com-host-callable.slang
index 75c985040..e41eed8ef 100644
--- a/tools/slang-unit-test/unit-test-com-host-callable.slang
+++ b/tools/slang-unit-test/unit-test-com-host-callable.slang
@@ -2,19 +2,19 @@
// Example of using 'NativeString'
-public __extern_cpp NativeString getString(NativeString in)
+export __extern_cpp NativeString getString(NativeString in)
{
return in;
}
-public __extern_cpp __global int intGlobal = 10;
+export __extern_cpp __global int intGlobal = 10;
-public __extern_cpp void setGlobal(int v)
+export __extern_cpp void setGlobal(int v)
{
intGlobal = v;
}
-public __extern_cpp int getGlobal()
+export __extern_cpp int getGlobal()
{
return intGlobal;
}
@@ -32,19 +32,19 @@ interface ICountGood
int nextCount();
}
-public __extern_cpp __global ICountGood globalCounter;
+export __extern_cpp __global ICountGood globalCounter;
-public __extern_cpp void setCounter(ICountGood counter)
+export __extern_cpp void setCounter(ICountGood counter)
{
globalCounter = counter;
}
-public __extern_cpp int nextCount()
+export __extern_cpp int nextCount()
{
return globalCounter.nextCount();
}
-public __extern_cpp int calcHash(NativeString text, IDoThings doThings)
+export __extern_cpp int calcHash(NativeString text, IDoThings doThings)
{
return doThings.calcHash(text);
}
diff --git a/tools/slang-unit-test/unit-test-translation-unit-import.cpp b/tools/slang-unit-test/unit-test-translation-unit-import.cpp
index 3a0a98e17..b8108644e 100644
--- a/tools/slang-unit-test/unit-test-translation-unit-import.cpp
+++ b/tools/slang-unit-test/unit-test-translation-unit-import.cpp
@@ -18,7 +18,7 @@ SLANG_UNIT_TEST(translationUnitImport)
{
// Source for the first translation unit.
const char* generatedSource =
- "int f() {"
+ "public int f() {"
" return 5;"
"};";
@@ -28,7 +28,7 @@ SLANG_UNIT_TEST(translationUnitImport)
R"(
import generatedUnit;
- int g(){ return f(); }
+ public int g(){ return f(); }
)";
// Source for a module that transitively uses the generated source via a file.