简体   繁体   English

了解纹理如何与CUDA一起使用

[英]understanding how textures work with CUDA

I got confused of how textures work with CUDA 我对纹理如何与CUDA一起使用感到困惑

as when I do device Query "on my GTX 780" I find this: 当我在“ GTX 780上”进行设备查询时,我发现:

Maximum Texture Dimension Size (x,y,z)  1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)

now when I investigated CUDA "particles example", I found this: 现在,当我调查CUDA“粒子示例”时,我发现了这一点:

checkCudaErrors(cudaBindTexture(0, oldPosTex, sortedPos, numParticles*sizeof(float4)));

where numParticles in my case I have raised it to 1024 * 1024 * 2 (around 2.1 millions) 在我的情况下,numParticles已将其提高到1024 * 1024 * 2(约210万)

how does this fit in the 1D texture?? 这如何适合一维纹理?

also inside the kernels I've found this "need more explain please as everything here is connected" 同样在内核中,我发现这“需要更多解释,因为这里的所有内容都已连接”

texture<float4, 1, cudaReadModeElementType> oldPosTex;
#define FETCH(t, i) tex1Dfetch(t##Tex, i)

at kernel: 在内核:

float4 pos = FETCH(oldPos, sortedIndex); 

now what I need to know also, I can use this texture "with its defined size numParticles*sizeof(float4) in a frame buffer draw instead of drawing a VBO? 现在我还需要知道的是,我可以在帧缓冲区绘制中使用此纹理“及其定义的大小numParticles * sizeof(float4),而不是绘制VBO?

how does this fit in the 1D texture? 这如何适合1D纹理?

The texture hardware consists of two main parts, the texture filtering hardware and the texture cache. 纹理硬件包括两个主要部分,纹理过滤硬件和纹理缓存。 Texture filtering includes functionality such as interpolation, addressing by normalized floating point coordinates and handling out-of-bounds addresses (clamp, wrap, mirror and border addressing modes). 纹理过滤包括诸如插值,通过标准化浮点坐标进行寻址以及处理越界地址(钳位,环绕,镜像和边界寻址模式)之类的功能。 The texture cache can store data in a space filling curve to maximize 2D spatial locality (and thereby the cache hit rate). 纹理缓存可以将数据存储在空间填充曲线中,以最大化2D空间局部性(从而最大化缓存命中率)。 It can also store data in a regular flat array. 它还可以将数据存储在常规平面阵列中。

The Maximum Texture Dimension Size refers to limitations in the texture filtering hardware, not the texture caching hardware. Maximum Texture Dimension Size是指纹理过滤硬件中的限制,而不是纹理缓存硬件中的限制。 And so, it refers to limits you may hit when using functions like tex2D() but not when using functions like tex1Dfetch() , which performs an unfiltered texture lookup. 因此,它指的是使用tex2D()类的函数时可能会遇到的限制,但使用tex1Dfetch()类的tex1Dfetch()未执行未过滤纹理查找tex1Dfetch()时可能达到的极限。 So, code you gave is probably setting things up for tex1Dfetch() . 因此,您提供的代码可能是为tex1Dfetch()

need more explain please as everything here is connected 需要更多的解释,因为这里的一切都连接

This question is too broad and may be why your question was downvoted. 这个问题范围太广,可能是您的问题被否决的原因。

now what I need to know also, I can use this texture "with its defined size numParticles*sizeof(float4) in a frame buffer draw instead of drawing a VBO? 现在我还需要知道的是,我可以在帧缓冲区绘制中使用此纹理“及其定义的大小numParticles * sizeof(float4),而不是绘制VBO?

This is not a CUDA question as CUDA cannot draw anything. 这不是CUDA的问题,因为CUDA无法绘制任何内容。 You should look into CUDA OpenGL interop to see if your question is answered there. 您应该查看CUDA OpenGL互操作,以查看您的问题是否得到了回答。 If it's not, you should create a new question and describe your question more clearly. 如果不是,则应创建一个新问题并更清楚地描述您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM