diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2022-11-07 17:59:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-07 08:59:15 -0800 |
| commit | ea99c274dea12fffdc89a8d4eeefcbb670232ba8 (patch) | |
| tree | fde86d173a4cca226433ec689c10dcc173b4fd16 /tools/gfx/cuda | |
| parent | 72ce0584d273ac5f04c3d9096f3523da68cc6fc1 (diff) | |
Initial version of DeviceLimits implemented in d3d12, d3d11, vulkan and cuda (#2496)
Diffstat (limited to 'tools/gfx/cuda')
| -rw-r--r-- | tools/gfx/cuda/cuda-device.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp index 76538cfad..f81bcfe99 100644 --- a/tools/gfx/cuda/cuda-device.cpp +++ b/tools/gfx/cuda/cuda-device.cpp @@ -184,6 +184,9 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) m_features.add("half"); } + cudaDeviceProp deviceProps; + cudaGetDeviceProperties(&deviceProps, m_deviceIndex); + // Initialize DeviceInfo { m_info.deviceType = DeviceType::CUDA; @@ -192,13 +195,42 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) m_info.apiName = "CUDA"; static const float kIdentity[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; ::memcpy(m_info.identityProjectionMatrix, kIdentity, sizeof(kIdentity)); - cudaDeviceProp deviceProperties; - cudaGetDeviceProperties(&deviceProperties, m_deviceIndex); - m_adapterName = deviceProperties.name; + m_adapterName = deviceProps.name; m_info.adapterName = m_adapterName.begin(); m_info.timestampFrequency = 1000000; } + // Get device limits. + { + DeviceLimits limits = {}; + limits.maxTextureDimension1D = deviceProps.maxSurface1D; + limits.maxTextureDimension2D = Math::Min(deviceProps.maxSurface2D[0], deviceProps.maxSurface2D[1]); + limits.maxTextureDimension3D = Math::Min(deviceProps.maxSurface3D[0], Math::Min(deviceProps.maxSurface3D[1], deviceProps.maxSurface3D[2])); + limits.maxTextureDimensionCube = deviceProps.maxSurfaceCubemap; + limits.maxTextureArrayLayers = Math::Min(deviceProps.maxSurface1DLayered[2], deviceProps.maxSurface2DLayered[2]); + + // limits.maxVertexInputElements + // limits.maxVertexInputElementOffset + // limits.maxVertexStreams + // limits.maxVertexStreamStride + + limits.maxComputeThreadsPerGroup = deviceProps.maxThreadsPerBlock; + limits.maxComputeThreadGroupSize[0] = deviceProps.maxThreadsDim[0]; + limits.maxComputeThreadGroupSize[1] = deviceProps.maxThreadsDim[1]; + limits.maxComputeThreadGroupSize[2] = deviceProps.maxThreadsDim[2]; + limits.maxComputeDispatchThreadGroups[0] = deviceProps.maxGridSize[0]; + limits.maxComputeDispatchThreadGroups[1] = deviceProps.maxGridSize[1]; + limits.maxComputeDispatchThreadGroups[2] = deviceProps.maxGridSize[2]; + + // limits.maxViewports + // limits.maxViewportDimensions + // limits.maxFramebufferDimensions + + // limits.maxShaderVisibleSamplers + + m_info.limits = limits; + } + return SLANG_OK; } |
