Fix cast from uniform struct to varying struct.
This commit is contained in:
3
expr.cpp
3
expr.cpp
@@ -6786,7 +6786,8 @@ lUniformValueToVarying(FunctionEmitContext *ctx, llvm::Value *value,
|
|||||||
|
|
||||||
for (int i = 0; i < collectionType->GetElementCount(); ++i) {
|
for (int i = 0; i < collectionType->GetElementCount(); ++i) {
|
||||||
llvm::Value *v = ctx->ExtractInst(value, i, "get_element");
|
llvm::Value *v = ctx->ExtractInst(value, i, "get_element");
|
||||||
v = lUniformValueToVarying(ctx, v, collectionType->GetElementType(i));
|
if (collectionType->GetElementType(i)->IsVaryingType())
|
||||||
|
v = lUniformValueToVarying(ctx, v, collectionType->GetElementType(i));
|
||||||
retValue = ctx->InsertInst(retValue, v, i, "set_element");
|
retValue = ctx->InsertInst(retValue, v, i, "set_element");
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|||||||
23
tests/struct-test-126.ispc
Normal file
23
tests/struct-test-126.ispc
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
export uniform int width() { return programCount; }
|
||||||
|
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
uniform float x;
|
||||||
|
varying float y;
|
||||||
|
};
|
||||||
|
|
||||||
|
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||||
|
float a = aFOO[programIndex];
|
||||||
|
uniform Foo struct_1;
|
||||||
|
struct_1.x = b;
|
||||||
|
struct_1.y = aFOO[programIndex];
|
||||||
|
varying Foo struct_2 = struct_1;
|
||||||
|
RET[programIndex] = struct_2.x + struct_2.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export void result(uniform float RET[]) {
|
||||||
|
RET[programIndex] = 5 + programIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user