diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-02-05 12:37:03 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-05 10:37:03 -0800 |
| commit | 9ec6b91686b651d959fd9ffbec283845bd725dd6 (patch) | |
| tree | 2c48202cb04b76e5ddcb274be35529378ddf8f31 /tools/gfx | |
| parent | 4b350645042b8e8fbdad19784ee745d11c7bc616 (diff) | |
Feature/initialize list side branch (#6058)
* SP004: implement initialize list translation to ctor
- We synthesize a member-wise constructor for each struct follow
the rules described in SP004.
- Add logic to translate the initialize list to constructor invoke
- Add cuda-host decoration for the synthesized constructor
- Remove the default constructor when we have a valid member init constructor
- Disable -zero-initialize option, will re-implement it in followup (#6109).
- Fix the overload lookup issue
When creating invoke expression for ctor, we need to call
ResolveInvoke() to find us the best candidates, however
the existing lookup logic could find us the base constructor
for child struct, we should eliminate this case by providing
the LookupOptions::IgnoreInheritance to lookup, this requires
us to create a subcontext on SemanticsVisitor to indicate that
we only want to use this option on looking the constructor.
- Do not implicit initialize a struct that doesn't have explicit default
constructor.
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tools/gfx')
| -rw-r--r-- | tools/gfx/gfx.slang | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/tools/gfx/gfx.slang b/tools/gfx/gfx.slang index e14f5e282..fded20eeb 100644 --- a/tools/gfx/gfx.slang +++ b/tools/gfx/gfx.slang @@ -105,9 +105,9 @@ public enum class ShaderModuleSourceType public struct ShaderProgramDesc2 { - public ShaderModuleSourceType sourceType; - public void *sourceData; - public Size sourceDataSize; + public ShaderModuleSourceType sourceType = ShaderModuleSourceType::SlangSource; + public void *sourceData = nullptr; + public Size sourceDataSize = 0; // Number of entry points to include in the shader program. 0 means include all entry points // defined in the module. @@ -345,7 +345,7 @@ public enum class InteropHandleAPI public struct InteropHandle { public InteropHandleAPI api = InteropHandleAPI::Unknown; - public uint64_t handleValue; + public uint64_t handleValue = 0LLU; }; // Declare opaque type @@ -378,12 +378,12 @@ public enum class ResourceType /// Base class for Descs public struct ResourceDescBase { - public ResourceType type; - public ResourceState defaultState; - public ResourceStateSet allowedStates; - public MemoryType memoryType; - public InteropHandle existingHandle; - public bool isShared; + public ResourceType type = ResourceType::Unknown; + public ResourceState defaultState = ResourceState::Undefined; + public ResourceStateSet allowedStates = {}; + public MemoryType memoryType = MemoryType::DeviceLocal; + public InteropHandle existingHandle = {}; + public bool isShared = false; }; [COM("a0e39f34-8398-4522-95c2-ebc0f984ef3f")] @@ -1056,6 +1056,7 @@ public struct AspectBlendDesc { srcFactor = BlendFactor::One; dstFactor = BlendFactor::Zero; + op = BlendOp::Add; } }; @@ -1076,10 +1077,10 @@ public struct TargetBlendDesc public struct BlendDesc { - public TargetBlendDesc targets[kMaxRenderTargetCount]; - public GfxCount targetCount; + public TargetBlendDesc targets[kMaxRenderTargetCount] = {}; + public GfxCount targetCount = 0; - public bool alphaToCoverageEnable; + public bool alphaToCoverageEnable = false; }; public struct FramebufferTargetLayout @@ -1113,7 +1114,13 @@ public struct GraphicsPipelineStateDesc public __init() { + program = {IShaderProgram()}; + inputLayout = {IInputLayout()}; + framebufferLayout = {IFramebufferLayout()}; primitiveType = PrimitiveType::Triangle; + depthStencil = {}; + rasterizer = {}; + blend = {}; } }; @@ -1230,14 +1237,14 @@ public struct WindowHandle public void* handleValues[2]; public static WindowHandle fromHwnd(void *hwnd) { - WindowHandle handle = {}; + WindowHandle handle = {WindowHandleType::Unknown, {nullptr, nullptr}}; handle.type = WindowHandleType::Win32Handle; handle.handleValues[0] = hwnd; return handle; } public static WindowHandle fromXWindow(void *xdisplay, uint32_t xwindow) { - WindowHandle handle = {}; + WindowHandle handle = {WindowHandleType::Unknown, {nullptr, nullptr}}; handle.type = WindowHandleType::XLibHandle; handle.handleValues[0] = xdisplay; handle.handleValues[1] = (void*)xwindow; @@ -1698,17 +1705,17 @@ public interface IDebugCallback public struct SlangDesc { - public NativeRef<slang::IGlobalSession> slangGlobalSession; // (optional) A slang global session object. If null will create automatically. + public NativeRef<slang::IGlobalSession> slangGlobalSession = {slang::IGlobalSession()}; // (optional) A slang global session object. If null will create automatically. public slang::SlangMatrixLayoutMode defaultMatrixLayoutMode = slang::SlangMatrixLayoutMode::SLANG_MATRIX_LAYOUT_ROW_MAJOR; - public NativeString *searchPaths; - public GfxCount searchPathCount; + public NativeString *searchPaths = nullptr; + public GfxCount searchPathCount = 0; - public slang::PreprocessorMacroDesc *preprocessorMacros; + public slang::PreprocessorMacroDesc *preprocessorMacros = nullptr; public GfxCount preprocessorMacroCount = 0; - public NativeString targetProfile; // (optional) Target shader profile. If null this will be set to platform dependent 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; @@ -1718,7 +1725,7 @@ public struct SlangDesc public struct ShaderCacheDesc { // The root directory for the shader cache. If not set, shader cache is disabled. - public NativeString shaderCachePath; + public NativeString shaderCachePath = ""; // The maximum number of entries stored in the cache. public GfxCount maxEntryCount = 0; }; @@ -1735,9 +1742,9 @@ public struct DeviceDesc // 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. - public DeviceInteropHandles existingDeviceHandles; + public DeviceInteropHandles existingDeviceHandles = {}; // Name to identify the adapter to use - public NativeString adapter; + public NativeString adapter = ""; // Number of required features. public GfxCount requiredFeatureCount = 0; // Array of required feature names, whose size is `requiredFeatureCount`. |
