[英]When using Direct 3D, what should be processed in code and what should be processed in HLSL?
I am very new to 3D programming, namely with DirectX. 我是3D编程的新手,即使用DirectX。 I have been trying to follow tutorials on how to do basic things, and I have been looking at the samples provided by Microsoft.
我一直在尝试按照如何做基本事情的教程,我一直在看微软提供的示例。 One of the big questions I have had is how to tell what calculations should be done in the actual game code and what calculations should be done in HLSL.
我遇到的一个重大问题是如何判断在实际游戏代码中应该进行哪些计算以及在HLSL中应该进行哪些计算。 I have not been able to understand what should be done where, because it looks like, to me, you could have almost all code pertaining to calculations in your shader file, or you could have it all in the executable code and only send the bear minimum to the pixel and vertex shaders.
我无法理解应该在哪里做什么,因为看起来,对我来说,你几乎可以拥有与着色器文件中的计算相关的所有代码,或者你可以将它全部放在可执行代码中并且只发送熊最小的像素和顶点着色器。 How can one tell what code should go where?
如何判断代码应该放在哪里? If you need an example, I'll try to find one.
如果你需要一个例子,我会试着找一个。
"Code" - CPU code “代码” - CPU代码
"HLSL" - GPU code “HLSL” - GPU代码
Basically, you want everything that is pure graphics to happen on the GPU. 基本上,您希望所有纯图形都在GPU上发生。 That is, when the information about what you want to render has been sent to the GPU, it should take over and use that information to generate the final image.
也就是说,当有关您要渲染的内容的信息已发送到GPU时,它应接管并使用该信息生成最终图像。
You want to the CPU to say to the GPU "this is what I want to render, and here is everything you need to make it happen" and then make sure to tell the GPU "this is how you render it" . 你想让CPU对GPU说“这就是我要呈现的内容,这里就是你需要做的一切” ,然后确保告诉GPU “这就是你渲染它的方式” 。
Some examples (not a complete or final list in anyway): 一些例子(无论如何都不是完整的或最终的列表):
CPU: 中央处理器:
GPU: GPU:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.