summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--slang-gfx.h42
-rw-r--r--tools/gfx/cuda/cuda-device.cpp38
-rw-r--r--tools/gfx/d3d11/d3d11-device.cpp75
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp34
-rw-r--r--tools/gfx/vulkan/vk-device.cpp34
5 files changed, 220 insertions, 3 deletions
diff --git a/slang-gfx.h b/slang-gfx.h
index 7b8107179..590d7d5c7 100644
--- a/slang-gfx.h
+++ b/slang-gfx.h
@@ -2122,10 +2122,52 @@ private:
ComPtr<ISlangBlob> m_blob;
};
+struct DeviceLimits
+{
+ /// Maximum dimension for 1D textures.
+ uint32_t maxTextureDimension1D;
+ /// Maximum dimensions for 2D textures.
+ uint32_t maxTextureDimension2D;
+ /// Maximum dimensions for 3D textures.
+ uint32_t maxTextureDimension3D;
+ /// Maximum dimensions for cube textures.
+ uint32_t maxTextureDimensionCube;
+ /// Maximum number of texture layers.
+ uint32_t maxTextureArrayLayers;
+
+ /// Maximum number of vertex input elements in a graphics pipeline.
+ uint32_t maxVertexInputElements;
+ /// Maximum offset of a vertex input element in the vertex stream.
+ uint32_t maxVertexInputElementOffset;
+ /// Maximum number of vertex streams in a graphics pipeline.
+ uint32_t maxVertexStreams;
+ /// Maximum stride of a vertex stream.
+ uint32_t maxVertexStreamStride;
+
+ /// Maximum number of threads per thread group.
+ uint32_t maxComputeThreadsPerGroup;
+ /// Maximum dimensions of a thread group.
+ uint32_t maxComputeThreadGroupSize[3];
+ /// Maximum number of thread groups per dimension in a single dispatch.
+ uint32_t maxComputeDispatchThreadGroups[3];
+
+ /// Maximum number of viewports per pipeline.
+ uint32_t maxViewports;
+ /// Maximum viewport dimensions.
+ uint32_t maxViewportDimensions[2];
+ /// Maximum framebuffer dimensions.
+ uint32_t maxFramebufferDimensions[3];
+
+ /// Maximum samplers visible in a shader stage.
+ uint32_t maxShaderVisibleSamplers;
+};
+
struct DeviceInfo
{
DeviceType deviceType;
+ DeviceLimits limits;
+
BindingStyle bindingStyle;
ProjectionStyle projectionStyle;
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;
}
diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp
index 4872d2a54..f15c94da6 100644
--- a/tools/gfx/d3d11/d3d11-device.cpp
+++ b/tools/gfx/d3d11/d3d11-device.cpp
@@ -212,6 +212,81 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
m_immediateContext->GetData(m_disjointQuery, &disjointData, sizeof(disjointData), 0);
m_info.timestampFrequency = disjointData.Frequency;
}
+
+ // Get device limits.
+ {
+ uint32_t maxTextureDimensionUV = 2048;
+ if (featureLevel >= D3D_FEATURE_LEVEL_9_3)
+ maxTextureDimensionUV = 4096;
+ if (featureLevel >= D3D_FEATURE_LEVEL_10_0)
+ maxTextureDimensionUV = 8192;
+ if (featureLevel >= D3D_FEATURE_LEVEL_11_0)
+ maxTextureDimensionUV = 16384;
+
+ uint32_t maxTextureDimensionW = 256;
+ if (featureLevel >= D3D_FEATURE_LEVEL_10_0)
+ maxTextureDimensionW = 2048;
+
+ uint32_t maxTextureDimensionCube = 512;
+ if (featureLevel >= D3D_FEATURE_LEVEL_9_3)
+ maxTextureDimensionCube = maxTextureDimensionUV;
+
+ uint32_t maxInputElements = 16;
+ if (featureLevel >= D3D_FEATURE_LEVEL_10_1)
+ maxInputElements = 32;
+
+ uint32_t maxColorAttachments = 4;
+ if (featureLevel >= D3D_FEATURE_LEVEL_10_1)
+ maxColorAttachments = 8;
+
+ uint32_t maxComputeThreadGroupSizeXY = 0;
+ uint32_t maxComputeThreadGroupSizeZ = 0;
+ uint32_t maxComputeDispatchThreadGroupsZ = 0;
+ if (featureLevel >= D3D_FEATURE_LEVEL_10_0)
+ {
+ maxComputeThreadGroupSizeXY = D3D11_CS_4_X_THREAD_GROUP_MAX_X;
+ maxComputeThreadGroupSizeZ = 1;
+ maxComputeDispatchThreadGroupsZ = 1;
+ }
+ if (featureLevel >= D3D_FEATURE_LEVEL_11_0)
+ {
+ maxComputeThreadGroupSizeXY = D3D11_CS_THREAD_GROUP_MAX_X;
+ maxComputeThreadGroupSizeZ = D3D11_CS_THREAD_GROUP_MAX_Z;
+ maxComputeDispatchThreadGroupsZ = D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ }
+
+ DeviceLimits limits = {};
+ limits.maxTextureDimension1D = maxTextureDimensionUV;
+ limits.maxTextureDimension2D = maxTextureDimensionUV;
+ limits.maxTextureDimension3D = maxTextureDimensionW;
+ limits.maxTextureDimensionCube = maxTextureDimensionCube;
+ limits.maxTextureArrayLayers = maxTextureDimensionCube;
+
+ limits.maxVertexInputElements = maxInputElements;
+ limits.maxVertexInputElementOffset = 256; // TODO
+ limits.maxVertexStreams = D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ;
+ limits.maxVertexStreamStride = D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES;
+
+ limits.maxComputeThreadsPerGroup = D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
+ limits.maxComputeThreadGroupSize[0] = maxComputeThreadGroupSizeXY;
+ limits.maxComputeThreadGroupSize[1] = maxComputeThreadGroupSizeXY;
+ limits.maxComputeThreadGroupSize[2] = maxComputeThreadGroupSizeZ;
+ limits.maxComputeDispatchThreadGroups[0] = D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[1] = D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[2] = maxComputeDispatchThreadGroupsZ;
+
+ limits.maxViewports = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
+ limits.maxViewportDimensions[0] = D3D11_VIEWPORT_BOUNDS_MAX;
+ limits.maxViewportDimensions[1] = D3D11_VIEWPORT_BOUNDS_MAX;
+ limits.maxFramebufferDimensions[0] = 4096; // TODO
+ limits.maxFramebufferDimensions[1] = 4096; // TODO
+ limits.maxFramebufferDimensions[2] = 1;
+
+ limits.maxShaderVisibleSamplers = D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
+
+ m_info.limits = limits;
+ }
+
return SLANG_OK;
}
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index ebb416c39..3c6a98c2b 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -725,6 +725,40 @@ Result DeviceImpl::initialize(const Desc& desc)
// Retrieve timestamp frequency.
m_resourceCommandQueue->m_d3dQueue->GetTimestampFrequency(&m_info.timestampFrequency);
+ // Get device limits.
+ {
+ DeviceLimits limits = {};
+ limits.maxTextureDimension1D = D3D12_REQ_TEXTURE1D_U_DIMENSION;
+ limits.maxTextureDimension2D = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ limits.maxTextureDimension3D = D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
+ limits.maxTextureDimensionCube = D3D12_REQ_TEXTURECUBE_DIMENSION;
+ limits.maxTextureArrayLayers = D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
+
+ limits.maxVertexInputElements = D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT;
+ limits.maxVertexInputElementOffset = 256; // TODO
+ limits.maxVertexStreams = D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT;
+ limits.maxVertexStreamStride = D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES;
+
+ limits.maxComputeThreadsPerGroup = D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
+ limits.maxComputeThreadGroupSize[0] = D3D12_CS_THREAD_GROUP_MAX_X;
+ limits.maxComputeThreadGroupSize[1] = D3D12_CS_THREAD_GROUP_MAX_Y;
+ limits.maxComputeThreadGroupSize[2] = D3D12_CS_THREAD_GROUP_MAX_Z;
+ limits.maxComputeDispatchThreadGroups[0] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[1] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[2] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+
+ limits.maxViewports = D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
+ limits.maxViewportDimensions[0] = D3D12_VIEWPORT_BOUNDS_MAX;
+ limits.maxViewportDimensions[1] = D3D12_VIEWPORT_BOUNDS_MAX;
+ limits.maxFramebufferDimensions[0] = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ limits.maxFramebufferDimensions[1] = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION;
+ limits.maxFramebufferDimensions[2] = 1;
+
+ limits.maxShaderVisibleSamplers = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE;
+
+ m_info.limits = limits;
+ }
+
SLANG_RETURN_ON_FAIL(createTransientResourceHeapImpl(
ITransientResourceHeap::Flags::AllowResizing,
0,
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp
index e4e707001..d182a066d 100644
--- a/tools/gfx/vulkan/vk-device.cpp
+++ b/tools/gfx/vulkan/vk-device.cpp
@@ -321,6 +321,40 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
// Compute timestamp frequency.
m_info.timestampFrequency = uint64_t(1e9 / basicProps.limits.timestampPeriod);
+ // Get device limits.
+ {
+ DeviceLimits limits = {};
+ limits.maxTextureDimension1D = basicProps.limits.maxImageDimension1D;
+ limits.maxTextureDimension2D = basicProps.limits.maxImageDimension2D;
+ limits.maxTextureDimension3D = basicProps.limits.maxImageDimension3D;
+ limits.maxTextureDimensionCube = basicProps.limits.maxImageDimensionCube;
+ limits.maxTextureArrayLayers = basicProps.limits.maxImageArrayLayers;
+
+ limits.maxVertexInputElements = basicProps.limits.maxVertexInputAttributes;
+ limits.maxVertexInputElementOffset = basicProps.limits.maxVertexInputAttributeOffset;
+ limits.maxVertexStreams = basicProps.limits.maxVertexInputBindings;
+ limits.maxVertexStreamStride = basicProps.limits.maxVertexInputBindingStride;
+
+ limits.maxComputeThreadsPerGroup = basicProps.limits.maxComputeWorkGroupInvocations;
+ limits.maxComputeThreadGroupSize[0] = basicProps.limits.maxComputeWorkGroupSize[0];
+ limits.maxComputeThreadGroupSize[1] = basicProps.limits.maxComputeWorkGroupSize[1];
+ limits.maxComputeThreadGroupSize[2] = basicProps.limits.maxComputeWorkGroupSize[2];
+ limits.maxComputeDispatchThreadGroups[0] = basicProps.limits.maxComputeWorkGroupCount[0];
+ limits.maxComputeDispatchThreadGroups[1] = basicProps.limits.maxComputeWorkGroupCount[1];
+ limits.maxComputeDispatchThreadGroups[2] = basicProps.limits.maxComputeWorkGroupCount[2];
+
+ limits.maxViewports = basicProps.limits.maxViewports;
+ limits.maxViewportDimensions[0] = basicProps.limits.maxViewportDimensions[0];
+ limits.maxViewportDimensions[1] = basicProps.limits.maxViewportDimensions[1];
+ limits.maxFramebufferDimensions[0] = basicProps.limits.maxFramebufferWidth;
+ limits.maxFramebufferDimensions[1] = basicProps.limits.maxFramebufferHeight;
+ limits.maxFramebufferDimensions[2] = basicProps.limits.maxFramebufferLayers;
+
+ limits.maxShaderVisibleSamplers = basicProps.limits.maxPerStageDescriptorSamplers;
+
+ m_info.limits = limits;
+ }
+
// Get the API version
const uint32_t majorVersion = VK_VERSION_MAJOR(basicProps.apiVersion);
const uint32_t minorVersion = VK_VERSION_MINOR(basicProps.apiVersion);