Skip to content

Commit da3b10d

Browse files
authored
Merge branch 'master' into aleino/unit-test-documentation
2 parents bb74a87 + a09d554 commit da3b10d

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

source/slang/slang-ir.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -4047,7 +4047,7 @@ IRInst* IRBuilder::emitCast(IRType* type, IRInst* value, bool fallbackToBuiltinC
40474047
/* From Float */
40484048
{kIROp_CastFloatToInt,
40494049
kIROp_FloatCast,
4050-
{kIROp_CastFloatToInt, kIROp_IntCast},
4050+
{kIROp_Neq},
40514051
{kIROp_CastFloatToInt, kIROp_CastIntToPtr},
40524052
kIROp_CastToVoid},
40534053
/* From Bool */
@@ -4079,6 +4079,13 @@ IRInst* IRBuilder::emitCast(IRType* type, IRInst* value, bool fallbackToBuiltinC
40794079
matType->getColumnCount(),
40804080
matType->getLayout());
40814081
}
4082+
4083+
if (op.op0 == kIROp_Neq)
4084+
{
4085+
IRInst* args[2] = {value, emitDefaultConstruct(value->getDataType())};
4086+
return emitIntrinsicInst(type, op.op0, 2, args);
4087+
}
4088+
40824089
auto result = emitIntrinsicInst(t, op.op0, 1, &value);
40834090
if (op.op1 != kIROp_Nop)
40844091
{

source/slang/slang.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,6 @@ Session::createSession(slang::SessionDesc const& inDesc, slang::ISession** outSe
816816
new TypeCheckingCache(*static_cast<TypeCheckingCache*>(m_typeCheckingCache.get()));
817817
}
818818

819-
linkage->setMatrixLayoutMode(desc.defaultMatrixLayoutMode);
820-
821819
Int searchPathCount = desc.searchPathCount;
822820
for (Int ii = 0; ii < searchPathCount; ++ii)
823821
{
@@ -845,6 +843,10 @@ Session::createSession(slang::SessionDesc const& inDesc, slang::ISession** outSe
845843

846844
linkage->m_optionSet.load(desc.compilerOptionEntryCount, desc.compilerOptionEntries);
847845

846+
if (!linkage->m_optionSet.hasOption(CompilerOptionName::MatrixLayoutColumn) &&
847+
!linkage->m_optionSet.hasOption(CompilerOptionName::MatrixLayoutRow))
848+
linkage->setMatrixLayoutMode(desc.defaultMatrixLayoutMode);
849+
848850
{
849851
const Int targetCount = desc.targetCount;
850852
const uint8_t* targetDescPtr = reinterpret_cast<const uint8_t*>(desc.targets);

tests/bugs/float-to-bool.slang

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -xslang -Wno-30081
2+
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -xslang -Wno-30081
3+
4+
//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0 0], stride = 4)
5+
RWStructuredBuffer<int> outputBuffer;
6+
7+
//TEST_INPUT: set inputBuffer = ubuffer(data=[0.0 0.2 1.0 1.2], stride = 4)
8+
RWStructuredBuffer<float4> inputBuffer;
9+
[numthreads(1,1,1)]
10+
void computeMain()
11+
{
12+
bool4 bv = inputBuffer[0];
13+
outputBuffer[0] = bv.x;
14+
outputBuffer[1] = bv.y;
15+
outputBuffer[2] = bv.z;
16+
outputBuffer[3] = bv.w;
17+
bool b = inputBuffer[0].y;
18+
outputBuffer[4] = b;
19+
}
20+
21+
// CHECK: 0
22+
// CHECK: 1
23+
// CHECK: 1
24+
// CHECK: 1
25+
// CHECK: 1

0 commit comments

Comments
 (0)