Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Sampler1DArray<float4> st1DArray_f32v4;
//TEST_INPUT: TextureSampler2D(size=4, content = one, arrayLength=2):name st2DArray_f32v4
Sampler2DArray<float4> st2DArray_f32v4;

//TEST_INPUT: TextureSampler2D(size=4, content = one):name st2DMS_f32v4
//TEST_INPUT: TextureSampler2D(size=4, content = one, sampleCount = two, mipMaps=1, format=RGBA32Float):name st2DMS_f32v4
Sampler2DMS<float4> st2DMS_f32v4;

//
Expand Down Expand Up @@ -71,9 +71,9 @@ typealias CombinedDepth2d_array = _Texture<
>;


//TEST_INPUT: TextureSampler2D(size=4, content = zero):name cd2D
//TEST_INPUT: TextureSampler2D(size=4, content = zero, format=D32Float):name cd2D
CombinedDepth2d<float> cd2D;
//TEST_INPUT: TextureSampler2D(size=4, content = zero, arrayLength=2):name cd2DArray
//TEST_INPUT: TextureSampler2D(size=4, content = zero, arrayLength=2, format=D32Float):name cd2DArray
CombinedDepth2d_array<float> cd2DArray;

uint getNotMapped()
Expand Down
7 changes: 4 additions & 3 deletions tests/hlsl-intrinsic/texture/partial-resident-texture.slang
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Texture2DArray<float4> t2DArray_f32v4;
//TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name tCubeArray_f32v4
TextureCubeArray<float4> tCubeArray_f32v4;

//TEST_INPUT: Texture2D(size=4, content = one):name t2DMS_f32v4
//TEST_INPUT: Texture2D(size=4, content = one, format=RGBA32Float, sampleCount=two):name t2DMS_f32v4
Texture2DMS<float4> t2DMS_f32v4;

//
Expand Down Expand Up @@ -106,9 +106,9 @@ typealias depthcube_array = _Texture<
format
>;

//TEST_INPUT: Texture2D(size=4, content = zero):name d2D
//TEST_INPUT: Texture2D(size=4, content = zero, format=D32Float):name d2D
depth2d<float> d2D;
//TEST_INPUT: Texture2D(size=4, content = zero, arrayLength=2):name d2DArray
//TEST_INPUT: Texture2D(size=4, content = zero, arrayLength=2, format=D32Float):name d2DArray
depth2d_array<float> d2DArray;

uint getNotMapped()
Expand Down Expand Up @@ -235,6 +235,7 @@ bool TEST_load<T>(
int3 iuvs = int3(iuv, sampleIndex);

return true

&& (status = getNotMapped(), all(TN(T(1)) == t2DMS.Load(iuv, sampleIndex, offset, status))) && CheckAccessFullyMapped(status)
&& (status = getNotMapped(), all(TN(T(1)) == t2D.Load(iuvs, offset, status))) && CheckAccessFullyMapped(status)
// SPIRV does not support sparse buffer loads.
Expand Down
54 changes: 33 additions & 21 deletions tests/hlsl-intrinsic/texture/texture-intrinsics.slang
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,34 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=VK):-vk -emit-spirv-directly -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type

//TEST_INPUT: Texture1D(size=4, content = one):name t1D
//TEST_INPUT: Texture1D(size=4, format=D32Float, content = one):name t1D
Texture1D<float> t1D;
//TEST_INPUT: Texture2D(size=4, content = one):name t2D
//TEST_INPUT: Texture2D(size=4, format=D32Float, content = one):name t2D
Texture2D<float> t2D;
//TEST_INPUT: Texture3D(size=4, content = one):name t3D
//TEST_INPUT: Texture3D(size=4, format=D32Float, content = one):name t3D
Texture3D<float> t3D;
//TEST_INPUT: TextureCube(size=4, content = one):name tCube
//TEST_INPUT: TextureCube(size=4, format=D32Float, content = one):name tCube
TextureCube<float> tCube;

//TEST_INPUT: Texture1D(size=4, content = one, arrayLength=2):name t1DArray
//TEST_INPUT: Texture1D(size=4, format=D32Float, content = one, arrayLength=2):name t1DArray
Texture1DArray<float> t1DArray;
//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=2):name t2DArray
//TEST_INPUT: Texture2D(size=4, format=D32Float, content = one, arrayLength=2):name t2DArray
Texture2DArray<float> t2DArray;
//TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name tCubeArray
//TEST_INPUT: TextureCube(size=4, format=D32Float, content = one, arrayLength=2):name tCubeArray
TextureCubeArray<float> tCubeArray;

//TEST_INPUT: Texture2D(size=4, content = one):name t2D_RGBA
Texture2D<float> t2D_RGBA;
//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=2):name t2DArray_RGBA
Texture2DArray<float> t2DArray_RGBA;
//TEST_INPUT: TextureCube(size=4, content = one):name tCube_RGBA
TextureCube<float> tCube_RGBA;
//TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name tCubeArray_RGBA
TextureCubeArray<float> tCubeArray_RGBA;

//TEST_INPUT: Sampler:name samplerState
SamplerState samplerState;
//TEST_INPUT: Sampler:name shadowSampler
//TEST_INPUT: Sampler(depthCompare):name shadowSampler
SamplerComparisonState shadowSampler;


Expand Down Expand Up @@ -83,6 +92,7 @@ void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
float Object.SampleCmpLevelZero()
*/
// NOTE: These are having issues with vulkan (glsl)
// SampleCmpLevelZero() requires format with VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT.
val += t1D.SampleCmpLevelZero(shadowSampler, u, 0);
val += t2D.SampleCmpLevelZero(shadowSampler, float2(u, u), 0);
val += t1DArray.SampleCmpLevelZero(shadowSampler, float2(u, u), 0);
Expand All @@ -96,7 +106,8 @@ void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
// TextureCube does not have an offset version of this

// Status variant
#if !defined(VK)
#if !defined(VK)

val += t1D.SampleCmpLevelZero(shadowSampler, u, 0, 0, status);
val += t2D.SampleCmpLevelZero(shadowSampler, float2(u, u), 0, int2(0, 0), status);

Expand Down Expand Up @@ -268,44 +279,44 @@ void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
/*
<Template Type>4 Object.Gather()
*/
float4 f4 = t2D.Gather(samplerState, float2(u, u));
float4 f4 = t2D_RGBA.Gather(samplerState, float2(u, u));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = tCube.Gather(samplerState, normalize(float3(u, 1 - u, u)));
f4 = tCube_RGBA.Gather(samplerState, normalize(float3(u, 1 - u, u)));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = t2DArray.Gather(samplerState, float3(u, u, 0));
f4 = t2DArray_RGBA.Gather(samplerState, float3(u, u, 0));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = tCubeArray.Gather(samplerState, float4(normalize(float3(u, 1 - u, u)), 0));
f4 = tCubeArray_RGBA.Gather(samplerState, float4(normalize(float3(u, 1 - u, u)), 0));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

// Offset variant
f4 = t2D.Gather(samplerState, float2(u, u), int2(0, 0));
f4 = t2D_RGBA.Gather(samplerState, float2(u, u), int2(0, 0));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = t2DArray.Gather(samplerState, float3(u, u, 0), int2(0, 0));
f4 = t2DArray_RGBA.Gather(samplerState, float3(u, u, 0), int2(0, 0));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

// Object.GatherGreen()
f4 = t2D.GatherGreen(samplerState, float2(u, u), int2(1, 2));
f4 = t2D_RGBA.GatherGreen(samplerState, float2(u, u), int2(1, 2));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = t2D.GatherGreen(samplerState, float2(u, u), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
f4 = t2D_RGBA.GatherGreen(samplerState, float2(u, u), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = tCubeArray.GatherGreen(samplerState, float4(1.5, 1.5, 1.5, 1.5));
f4 = tCubeArray_RGBA.GatherGreen(samplerState, float4(1.5, 1.5, 1.5, 1.5));
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

// status variant
#if !defined(VK)
f4 = t2D.GatherGreen(samplerState, float2(u, u), int2(1, 2), status);
f4 = t2D_RGBA.GatherGreen(samplerState, float2(u, u), int2(1, 2), status);
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = t2D.GatherGreen(samplerState, float2(u, u), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
f4 = t2D_RGBA.GatherGreen(samplerState, float2(u, u), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
val += f4.x; val += f4.y; val += f4.z; val += f4.w;

f4 = tCubeArray.GatherGreen(samplerState, float4(1.5, 1.5, 1.5, 1.5), status);
f4 = tCubeArray_RGBA.GatherGreen(samplerState, float4(1.5, 1.5, 1.5, 1.5), status);
val += f4.x; val += f4.y; val += f4.z; val += f4.w;
#endif

Expand All @@ -331,6 +342,7 @@ void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
<Template Type> Object.SampleGrad()
*/
float _ddx = 0.0f, _ddy = 0.0f;

val += t1D.SampleGrad(samplerState, 0.0f, _ddx, _ddy);
val += t2D.SampleGrad(samplerState, float2(u, u), float2(_ddx, _ddx), float2(_ddy, _ddy));
val += t3D.SampleGrad(samplerState, float3(u, u, u), float3(_ddx, _ddx, _ddx), float3(_ddy, _ddy, _ddy));
Expand Down
40 changes: 20 additions & 20 deletions tests/metal/texture.slang
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,36 @@ Texture2DArray<half4> t2DArray_f16;
//TEST_INPUT: TextureCube(size=4, content = zero, arrayLength=2):name tCubeArray_f16
TextureCubeArray<half4> tCubeArray_f16;

//TEST_INPUT: Texture1D(size=4, content = zero):name t1D_i32
//TEST_INPUT: Texture1D(size=4, format=RGBA8Sint, content = zero):name t1D_i32
Texture1D<int4> t1D_i32;
//TEST_INPUT: Texture2D(size=4, content = zero):name t2D_i32
//TEST_INPUT: Texture2D(size=4, format=RGBA8Sint, content = zero):name t2D_i32
Texture2D<int4> t2D_i32;
//TEST_INPUT: Texture3D(size=4, content = zero):name t3D_i32
//TEST_INPUT: Texture3D(size=4, format=RGBA8Sint, content = zero):name t3D_i32
Texture3D<int4> t3D_i32;
//TEST_INPUT: TextureCube(size=4, content = zero):name tCube_i32
//TEST_INPUT: TextureCube(size=4, format=RGBA8Sint, content = zero):name tCube_i32
TextureCube<int4> tCube_i32;

//TEST_INPUT: Texture1D(size=4, content = zero, arrayLength=2):name t1DArray_i32
//TEST_INPUT: Texture1D(size=4, format=RGBA8Sint, content = zero, arrayLength=2):name t1DArray_i32
Texture1DArray<int4> t1DArray_i32;
//TEST_INPUT: Texture2D(size=4, content = zero, arrayLength=2):name t2DArray_i32
//TEST_INPUT: Texture2D(size=4, format=RGBA8Sint, content = zero, arrayLength=2):name t2DArray_i32
Texture2DArray<int4> t2DArray_i32;
//TEST_INPUT: TextureCube(size=4, content = zero, arrayLength=2):name tCubeArray_i32
//TEST_INPUT: TextureCube(size=4, format=RGBA8Sint, content = zero, arrayLength=2):name tCubeArray_i32
TextureCubeArray<int4> tCubeArray_i32;

//TEST_INPUT: Texture1D(size=4, content = zero):name t1D_u32
//TEST_INPUT: Texture1D(size=4, format=RGBA8Uint, content = zero):name t1D_u32
Texture1D<uint4> t1D_u32;
//TEST_INPUT: Texture2D(size=4, content = zero):name t2D_u32
//TEST_INPUT: Texture2D(size=4, format=RGBA8Uint, content = zero):name t2D_u32
Texture2D<uint4> t2D_u32;
//TEST_INPUT: Texture3D(size=4, content = zero):name t3D_u32
//TEST_INPUT: Texture3D(size=4, format=RGBA8Uint, content = zero):name t3D_u32
Texture3D<uint4> t3D_u32;
//TEST_INPUT: TextureCube(size=4, content = zero):name tCube_u32
//TEST_INPUT: TextureCube(size=4, format=RGBA8Uint, content = zero):name tCube_u32
TextureCube<uint4> tCube_u32;

//TEST_INPUT: Texture1D(size=4, content = zero, arrayLength=2):name t1DArray_u32
//TEST_INPUT: Texture1D(size=4, format=RGBA8Uint, content = zero, arrayLength=2):name t1DArray_u32
Texture1DArray<uint4> t1DArray_u32;
//TEST_INPUT: Texture2D(size=4, content = zero, arrayLength=2):name t2DArray_u32
//TEST_INPUT: Texture2D(size=4, format=RGBA8Uint, content = zero, arrayLength=2):name t2DArray_u32
Texture2DArray<uint4> t2DArray_u32;
//TEST_INPUT: TextureCube(size=4, content = zero, arrayLength=2):name tCubeArray_u32
//TEST_INPUT: TextureCube(size=4, format=RGBA8Uint, content = zero, arrayLength=2):name tCubeArray_u32
TextureCubeArray<uint4> tCubeArray_u32;

//TEST_INPUT: Texture1D(size=4, content = zero):name t1D_i16
Expand Down Expand Up @@ -173,18 +173,18 @@ typealias depthcube_array = _Texture<
format
>;

//TEST_INPUT: Texture2D(size=4, content = zero):name d2D
//TEST_INPUT: Texture2D(size=4, format=D32Float, content = zero):name d2D
depth2d<float> d2D;
//TEST_INPUT: TextureCube(size=4, content = zero):name dCube
//TEST_INPUT: TextureCube(size=4, format=D32Float, content = zero):name dCube
depthcube<float> dCube;
//TEST_INPUT: Texture2D(size=4, content = zero, arrayLength=2):name d2DArray
//TEST_INPUT: Texture2D(size=4, format=D32Float, content = zero, arrayLength=2):name d2DArray
depth2d_array<float> d2DArray;
//TEST_INPUT: TextureCube(size=4, content = zero, arrayLength=2):name dCubeArray
//TEST_INPUT: TextureCube(size=4, format=D32Float, content = zero, arrayLength=2):name dCubeArray
depthcube_array<float> dCubeArray;

//TEST_INPUT: Sampler:name samplerState
//TEST_INPUT: Sampler(filteringMode=point):name samplerState
SamplerState samplerState;
//TEST_INPUT: Sampler:name shadowSampler
//TEST_INPUT: Sampler(depthCompare):name shadowSampler
SamplerComparisonState shadowSampler;


Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/vulkan/vk-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
SIMPLE_EXTENSION_FEATURE(
extendedFeatures.computeShaderDerivativeFeatures,
computeDerivativeGroupLinear,
VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME,
VK_KHR_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME,
"computeDerivativeGroupLinear");

// Only enable raytracing validation if both requested and supported
Expand Down
26 changes: 21 additions & 5 deletions tools/render-test/shader-input-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ struct ShaderInputLayoutParser
{
val->samplerDesc.isCompareSampler = true;
}
else if (word == "filteringMode")
{
parser.Read("=");
auto contentWord = parser.ReadWord();
if (contentWord == "point")
{
val->samplerDesc.filteringMode = TextureFilteringMode::Point;
}
else
{
val->samplerDesc.filteringMode = TextureFilteringMode::Linear;
}
}
else
{
return SLANG_FAIL;
Expand Down Expand Up @@ -643,14 +656,15 @@ struct ShaderInputLayoutParser

default:
throw ShaderInputLayoutFormatException(
String("Unexpected '") + parser.NextToken().Content + String("' at line") +
String("Unexpected '") + parser.NextToken().Content + String("' at line ") +
String(parser.NextToken().Position.Line));
}
}

RefPtr<ShaderInputLayout::Val> parseVal(Misc::TokenReader& parser)
{
auto word = parser.NextToken().Content;
auto nextToken = parser.NextToken();
auto word = nextToken.Content;
if (parser.AdvanceIf("begin_array"))
{
RefPtr<ShaderInputLayout::ArrayVal> val = new ShaderInputLayout::ArrayVal;
Expand Down Expand Up @@ -820,8 +834,8 @@ struct ShaderInputLayoutParser
else
{
throw ShaderInputLayoutFormatException(
String("Unknown shader input type '") + word + String("' at line") +
String(parser.NextToken().Position.Line));
String("Unknown shader input type '") + word + String("' at line: ") +
String(nextToken.Position.Line));
}
parser.ReadToken();
return nullptr;
Expand Down Expand Up @@ -997,8 +1011,10 @@ struct ShaderInputLayoutParser
parentVal = rootVal;

auto lines = Misc::Split(source, '\n');
int lineNum = 0;
for (auto& line : lines)
{
lineNum++;
if (line.startsWith("//TEST_INPUT:"))
{
auto lineContent = line.subString(13, line.getLength() - 13);
Expand All @@ -1010,7 +1026,7 @@ struct ShaderInputLayoutParser
catch (const Misc::TextFormatException&)
{
StringBuilder msg;
msg << "Invalid input syntax at line " << parser.NextToken().Position.Line;
msg << "Invalid input syntax at line " << lineNum << ": " << line;
throw ShaderInputLayoutFormatException(msg);
}
}
Expand Down
10 changes: 6 additions & 4 deletions tools/render-test/shader-input-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct InputBufferDesc
struct InputSamplerDesc
{
bool isCompareSampler = false;
TextureFilteringMode filteringMode = TextureFilteringMode::Linear;
};

struct TextureData
Expand Down Expand Up @@ -109,7 +110,8 @@ struct TextureData
}
void* addSlice(size_t elemCount)
{
void* dst = ::malloc(m_formatSize * elemCount);
const size_t totalSize = m_formatSize * elemCount;
void* dst = ::malloc(totalSize);
m_slices.add(Slice::make(dst, elemCount));
return dst;
}
Expand Down Expand Up @@ -153,9 +155,9 @@ struct TextureData
uint8_t m_formatSize = 0;

Slang::List<Slice> m_slices;
int m_textureSize;
int m_mipLevels;
int m_arraySize;
int m_textureSize = 0;
int m_mipLevels = 1;
int m_arraySize = 1;
};

class ShaderInputLayout
Expand Down
Loading
Loading