91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Compute Shaders

發布時間:2020-07-19 08:53:14 來源:網絡 閱讀:474 作者:萌谷王 欄目:游戲開發

周一到周五,每天一篇,北京時間早上7點準時更新~

The first sections of this chapter describe the graphics pipeline in OpenGL(本章的第一個部分描述了OpenGL的圖形管線). However, OpenGL also includes the compute shader stage(OpenGL同樣包含Compute Shader的階段), which can almost be thought of as a separate pipeline that runs indepdendently of the other graphics-oriented stages(這個階段獨立的運行,不與其他繪圖相關的渲染管線階段有任何聯系). Compute shaders are a way of getting at the computational power possessed by the graphics processor in the system(Compute shader的目的是為了讓程序員得到圖形顯卡的計算能力). Unlike the graphics-centric vertex, tessellation, geometry, and fragment shaders, compute shaders could be considered as a special, single-stage pipeline all on their own(與其他shader不一樣,compute shader可以被認為是一個單獨的模塊). Each compute shader operates on a single unit of work known as a work item(每個compute shader把每一個數據單元做為工作對象); these items are, in turn, collected together into small groups called local workgroups(那些工作對象被組織成為組,被叫做本地工作組). Collections of these workgroups can be sent into OpenGL’s compute pipeline to be processed(大量的這樣的本地工作組可以被發送給OpenGL的compute shader處理階段進行處理). The compute shader doesn’t have any fixed inputs or outputs besides a handful of built-in variables to tell the shader which item it is working on(除了一些用于告訴shader它的工作對象的一些內置的控制變量以外,這個shader沒有任何固定的輸入和輸出的數據). All processing performed by a compute shader is explicitly written to memory by the shader itself, rather than being consumed by a subsequent pipeline stage(任何被顯示寫入內存的數據都是shader它自己完成的,而不是像其他shader一樣,輸出數據會被當成后面渲染階段的輸入). A very basic compute shader is shown in Listing 3.13 (Listing3.13展示了一個基本的compute shader)

#version 450 core
layout (local_size_x = 32, local_size_y = 32) in;
void main(void)
{
// Do nothing
}
Listing 3.13: Simple do-nothing compute shader

Compute shaders are otherwise just like any other shader stage in OpenGL(compute shaders就像是其他shader一樣). To compile one, you create a shader object with the type GL_COMPUTE_SHADER, attach yourGLSL source code to it with glShaderSource(), compile it with glCompileShader(), and then link it into a program with glAttachShader() and glLinkProgram()(你需要先創建shader、然后attach它給一個shader source,然后編譯它,鏈接成為GPU程序). The result is a program object with a compiled compute shader in it that can be launched to do work for you(編譯好了之后,就可以用于進行大規模的并行運算了)

The shader in Listing 3.13 tells OpenGL that the size of the local workgroup will be 32 by 32 work items, but then proceeds to do nothing(Listing3.13中的代碼告訴OpenGL本地工作組的大小是32x32,然而這個shader啥都沒做). To create a compute shader that actually does something useful, you need to know a bit more about OpenGL—so we’ll revisit this topic later in the book(為了創建一個compute shader并干點什么,你必須先了解以下OpenGL,所以我們將在后面的內容中再來討論這個話題)

本日的翻譯就到這里,明天見,拜拜~~

第一時間獲取最新橋段,請關注東漢書院以及圖形之心公眾號

東漢書院,等你來玩哦

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

喀喇| 肥东县| 工布江达县| 蒙城县| 龙山县| 宣化县| 阳信县| 剑河县| 抚顺县| 云和县| 松滋市| 建湖县| 彭泽县| 淮阳县| 枝江市| 景德镇市| 阿拉善左旗| 宁城县| 阜康市| 大新县| 乾安县| 大方县| 漳州市| 九龙城区| 米泉市| 无棣县| 建始县| 乌拉特后旗| 象州县| 文化| 呼伦贝尔市| 逊克县| 韶山市| 比如县| 巴青县| 靖宇县| 苗栗市| 深泽县| 商都县| 泽州县| 重庆市|