Skip to content

Commit

Permalink
fix gfx-smoke test
Browse files Browse the repository at this point in the history
Fix gfx-smoke test, for non-C style struct,

StructType a = {}; will never work anymore.
  • Loading branch information
kaizhangNV committed Jan 23, 2025
1 parent 2568072 commit 24d2208
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ cmake_policy(SET CMP0091 NEW)
# tree relocatable
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)

# Export the compile datebase as a json file, this can be used by VIM language server
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Enable placing targets into a hierarchy for IDE generators
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand Down
7 changes: 3 additions & 4 deletions source/slang/slang-check-decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12254,10 +12254,9 @@ bool SemanticsDeclAttributesVisitor::_searchMembersWithHigherVisibility(
{
for (auto param : ctor->getParameters())
{
if (getDeclVisibility(param) >= ctorVisibility)
{
resultMembers.add(param);
}
// Because the parameters in the ctor must have the higher or equal visibility than
// the ctor itself, we don't need to check the visibility level of the parameter.
resultMembers.add(param);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/cpu-program/gfx-smoke.slang
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export __extern_cpp int main()
return -1;
}

gfx.CommandQueueDesc queueDesc = {};
gfx.CommandQueueDesc queueDesc = {gfx::QueueType::Graphics};
queueDesc.type = gfx.QueueType.Graphics;
Optional<gfx.ICommandQueue> queue;
device.value.createCommandQueue(&queueDesc, queue);
Expand Down Expand Up @@ -42,12 +42,12 @@ export __extern_cpp int main()
device.value.createProgram2(&programDesc, program, diagBlob);

Optional<gfx.IPipelineState> pipeline;
gfx.ComputePipelineStateDesc pipelineDesc = {};
gfx.ComputePipelineStateDesc pipelineDesc;
pipelineDesc.program = NativeRef<gfx.IShaderProgram>(program.value);
device.value.createComputePipelineState(&pipelineDesc, pipeline);

Optional<gfx.ITransientResourceHeap> transientHeap;
gfx.TransientResourceHeapDesc transientHeapDesc = {};
gfx.TransientResourceHeapDesc transientHeapDesc;
transientHeapDesc.constantBufferDescriptorCount = 64;
transientHeapDesc.constantBufferSize = 1024;
transientHeapDesc.srvDescriptorCount = 1024;
Expand All @@ -67,7 +67,7 @@ export __extern_cpp int main()
device.value.createBufferResource(&bufferDesc, nullptr, buffer);

Optional<gfx.IResourceView> bufferView;
gfx.ResourceViewDesc viewDesc = {};
gfx.ResourceViewDesc viewDesc;
viewDesc.type = gfx.ResourceViewType.UnorderedAccess;
device.value.createBufferView(buffer.value, none, &viewDesc, bufferView);

Expand Down
14 changes: 7 additions & 7 deletions tools/gfx/gfx.slang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1230,14 +1230,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;
Expand Down Expand Up @@ -1698,17 +1698,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 = {}; // (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 GfxCount searchPathCount = 0;

public slang::PreprocessorMacroDesc *preprocessorMacros;
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;
Expand All @@ -1718,7 +1718,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;
};
Expand Down

0 comments on commit 24d2208

Please sign in to comment.