diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-06 12:05:07 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 12:05:07 -0800 |
| commit | 11111e5733b189127dc2c4934d67693b9bc6e764 (patch) | |
| tree | 0ba84df3e856eb104abec2ecac47242bc70a7b7d /tools | |
| parent | fa6d8717d02912697c09f2d7de802723ac6d6e47 (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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx-unit-test/shader-cache-tests.cpp | 4 | ||||
| -rw-r--r-- | tools/gfx/gfx.slang | 1264 | ||||
| -rw-r--r-- | tools/gfx/slang.slang | 126 | ||||
| -rw-r--r-- | tools/slang-unit-test/unit-test-com-host-callable.slang | 16 | ||||
| -rw-r--r-- | tools/slang-unit-test/unit-test-translation-unit-import.cpp | 4 |
5 files changed, 707 insertions, 707 deletions
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. |
