@@ -3969,78 +3969,85 @@ string GetSizeFunction(string textureName, string x, string y, string z)
39693969 if (config->getSizeExpression.size() > 0)
39703970 {
39713971 ShaderResourceType type = GetShaderResourceType(buildFunction, textureName);
3972- bool isImage = IsRW(type);
3973- bool isMsaa = IsMSAATexture(type);
3974- bool lod_param = !isImage && !isMsaa;
3975- int return_size = GetTextureDimension(type);
3976- string exp = config->getSizeExpression;
3977- if (isImage)
3972+ if (IsTexture(type))
39783973 {
3979- exp = config->getRWSizeExpression;
3980- // Legacy for GL
3981- find_and_replace(exp, "{type}", "imageSize");
3982- }
3983- else
3984- {
3985- // Legacy for GL
3986- find_and_replace(exp, "{type}", "textureSize");
3987- }
3988- string tempName = string("iv") + textureName;
3989- // Add sampler constructor
3990- if (type != ShaderResourceType::UNKNOWN)
3991- {
3992- find_and_replace(exp, "{return_size}", to_string(return_size));
3993- find_and_replace(exp, "{dim:{textureName}}", to_string(return_size));
3994- }
3995- find_and_replace(exp, "{dim:{textureName}}", string("{dim:") + textureName + "}");
3996- string nameToReplace = textureName;
3997- if (!isImage)
3998- {
3999- if (!config->combineInShader)
3974+ bool isImage = IsRW(type);
3975+ bool isMsaa = IsMSAATexture(type);
3976+ bool lod_param = !isImage && !isMsaa;
3977+ int return_size = GetTextureDimension(type);
3978+ string exp = config->getSizeExpression;
3979+ if (isImage)
40003980 {
4001- nameToReplace = GetSamplerConstructor(type, textureName, &buildFunction) + "(" + nameToReplace + "[0])";
3981+ exp = config->getRWSizeExpression;
3982+ // Legacy for GL
3983+ find_and_replace(exp, "{type}", "imageSize");
40023984 }
4003- }
4004- find_and_replace(exp, "{tmpName}", textureName);
4005- find_and_replace(exp, "{tempName}", tempName);
4006- find_and_replace(exp, "{textureName}", nameToReplace);
4007- // This case happens if the texture is passed as parameter with different name as the global,
4008- // we will defer this step
4009- if (type == ShaderResourceType::UNKNOWN)
4010- {
4011- find_and_replace(exp, "{args}", "{args" + textureName + "}");
4012- }
4013- else
4014- {
4015- if (lod_param && !isMsaa)
3985+ else
40163986 {
4017- find_and_replace(exp, "{args}", ",0");
3987+ // Legacy for GL
3988+ find_and_replace(exp, "{type}", "textureSize");
40183989 }
4019- else
3990+ string tempName = string("iv") + textureName;
3991+ // Add sampler constructor
3992+ if (type != ShaderResourceType::UNKNOWN)
40203993 {
4021- find_and_replace(exp, "{args}", "");
3994+ find_and_replace(exp, "{return_size}", to_string(return_size));
3995+ find_and_replace(exp, "{dim:{textureName}}", to_string(return_size));
40223996 }
4023- }
4024- full_expr << exp;
4025- if (type == ShaderResourceType::UNKNOWN)
4026- {
4027- full_expr << "{dim_check:" << textureName << "," << x << "," << y << "," << z << "," << tempName << "}";
4028- }
4029- else
4030- {
4031- if (return_size > 0 && x.size() > 0)
3997+ find_and_replace(exp, "{dim:{textureName}}", string("{dim:") + textureName + "}");
3998+ string nameToReplace = textureName;
3999+ if (!isImage)
4000+ {
4001+ if (!config->combineInShader)
4002+ {
4003+ nameToReplace = GetSamplerConstructor(type, textureName, &buildFunction) + "(" + nameToReplace + "[0])";
4004+ }
4005+ }
4006+ find_and_replace(exp, "{tmpName}", textureName);
4007+ find_and_replace(exp, "{tempName}", tempName);
4008+ find_and_replace(exp, "{textureName}", nameToReplace);
4009+ // This case happens if the texture is passed as parameter with different name as the global,
4010+ // we will defer this step
4011+ if (type == ShaderResourceType::UNKNOWN)
4012+ {
4013+ find_and_replace(exp, "{args}", "{args" + textureName + "}");
4014+ }
4015+ else
40324016 {
4033- full_expr << x << " = " + tempName + ".x;";
4017+ if (lod_param && !isMsaa)
4018+ {
4019+ find_and_replace(exp, "{args}", ",0");
4020+ }
4021+ else
4022+ {
4023+ find_and_replace(exp, "{args}", "");
4024+ }
40344025 }
4035- if (return_size > 1 && y.size() > 0)
4026+ full_expr << exp;
4027+ if (type == ShaderResourceType::UNKNOWN)
40364028 {
4037- full_expr << y << " = " + tempName + ".y; ";
4029+ full_expr << "{dim_check:" << textureName << "," << x << "," << y << "," << z << "," << tempName << "} ";
40384030 }
4039- if (return_size > 2 && z.size() > 0)
4031+ else
40404032 {
4041- full_expr << z << " = " + tempName + ".z;";
4033+ if (return_size > 0 && x.size() > 0)
4034+ {
4035+ full_expr << x << " = " + tempName + ".x;";
4036+ }
4037+ if (return_size > 1 && y.size() > 0)
4038+ {
4039+ full_expr << y << " = " + tempName + ".y;";
4040+ }
4041+ if (return_size > 2 && z.size() > 0)
4042+ {
4043+ full_expr << z << " = " + tempName + ".z;";
4044+ }
40424045 }
40434046 }
4047+ else //STRUCTURED_BUFFER and RW_STRUCTURED_BUFFER GetDeminsion for GLSL - AJR. TODO: Find a better solution to this!
4048+ {
4049+ full_expr << x << "=" << textureName << ".length()";
4050+ }
40444051 }
40454052 else
40464053 {
0 commit comments