来自C ++函数的HLSL着色器 [英] HLSL shader from c++ funtion
本文介绍了来自C ++函数的HLSL着色器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以使用此功能制作HLSL(高级着色器语言)着色器吗?
缓冲区可以表示为纹理.
我有1个源纹理(缓冲区)和1个目标纹理(缓冲区).
Can you make from this function HLSL (High Level Shader Language) shader?
Buffers can be presented as texture.
I have 1 source texture (buffer) and 1 destination texture (buffer).
void stretch_memory_R8G8B8A8(int source_height,int source_width,void *source_memory,int destination_height,int destination_width,void *destination_memory)
{
BYTE *destination_memory_BYTE = (BYTE *)destination_memory;
BYTE *source_memory_BYTE = (BYTE *)source_memory;
const double local_initial_value_width_0 = double(destination_width)/double(source_width);
for(int local_height_counter_source=0;local_height_counter_source<source_height;local_height_counter_source++)
{
int local_check_value_height = local_height_counter_source*destination_height/source_height+1+destination_height/source_height;
if(local_check_value_height>destination_height)
{
local_check_value_height = destination_height;
}
for(int local_height_counter_destination=local_height_counter_source*destination_height/source_height;
local_height_counter_destination<local_check_value_height;
local_height_counter_destination++)
{
for(int local_width_counter_source=0;local_width_counter_source<source_width;local_width_counter_source++)
{
int local_initial_value_width = local_width_counter_source*local_initial_value_width_0;
int local_check_value_width = local_initial_value_width+1+local_initial_value_width_0;
if(local_check_value_width>destination_width)
{
local_check_value_width = destination_width;
}
for(int local_width_counter_destination=local_initial_value_width;
local_width_counter_destination<local_check_value_width;
local_width_counter_destination++)
{
*(DWORD*)(&destination_memory_BYTE[(local_width_counter_destination+local_height_counter_destination*destination_width)<<2]) =
*(DWORD*)(&source_memory_BYTE[(local_width_counter_source+local_height_counter_source*source_width)<<2]);
}
}
}
}
}
推荐答案
是,但是使用了不同的方法.我所阅读的像素着色器将1个像素输入,不提供一个像素或提供一些像素输出,而您的函数可一次修改整个表面.实际的像素着色器功能将有效地执行外循环的一次迭代.和全局变量(HLSL globals)将保持循环状态,下一个绘制位置等等.
yes, but with a different approach. A pixel shader from what I have read takes 1 pixel in and provides either none or some pixels out, whereas your function modifies a whole surface at once. The actual pixel shader function would effectively do one iteration of the outer loop; and global variables ( HLSL globals ) would maintain the state of the loop, next draw position and so-forth.
这篇关于来自C ++函数的HLSL着色器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文