gpt4 book ai didi

image-processing - 你如何计算 HLSL 中的指令?

转载 作者:行者123 更新时间:2023-12-04 07:23:57 27 4
gpt4 key购买 nike

当我使用下面的代码时:


#define MAX_RADIUS 55
#define KERNEL_SIZE (MAX_RADIUS * 2 + 1)
...
float[] kernel[KERNEL_RADIUS];
...
float4 PS_GaussianBlur(float2 texCoord : TEXCOORD) : COLOR0
{
float4 color = float4(0.0f, 0.0f, 0.0f, 0.0f);

//add the right side offset pixels to the color
for (int i = 0; i < MAX_RADIUS; i++)
{
if(kernel[i] != 0) //this will improve performance for lower filter radius's, but increases const register num
color += tex2D(colorMap, texCoord + offsets[i]) * kernel[i];
}
//add the left side offset pixels to the color
for (int j = 0; j < MAX_RADIUS; j++)
{
if(kernel[i] != 0)
color += tex2D(colorMap, texCoord - offsets[j]) * kernel[j];
}
//finally add the weight of the original pixel to the color
color += tex2D(colorMap, texCoord) * kernel[MAX_RADIUS];

return color;
}

if(kernel[i] != 0) 显着增加了使用的指令数量!

所以我的问题是:是什么增加了指令数?为什么在只有 110 条指令长的循环中使用 if 语句会使指令数增加 400 多条?

编辑:以上问题已编辑。当它真的是指令时,我错误地认为寄存器被占用了。但是,这个问题仍然适用。什么会导致 2 个 for 循环(每个循环长度为 55)将指令数增加超过 400,而循环中仅添加 1 个 if 语句?

最佳答案

fxc 会给你一个指令计数。但实际上,你应该用另一种方式来做这件事。试试双向滤波器,一个通过 U,另一个通过 V?

关于image-processing - 你如何计算 HLSL 中的指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12852644/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com