重複對應的磚存取限制Tile access limitations with duplicate mappings

重複對應的磚有存取限制,例如複製來源和目的地重疊的資料流資源時,或轉譯至在轉譯區域中共用的磚時。There are limitations on tile access with duplicate mappings, such as when copying streaming resources with overlapping source and destination, or when rendering to tiles shared within the render area.

複製具有重疊的來源和目的地的資料流資源Copying streaming resources with overlapping source and destination

如果複製的來源和目的地區域中的磚*作業具有重複的對應區域中的複製會有重疊,即使這兩個資源已不在資源和複製串流*作業支援重疊複製時,複製*作業就會如同正常 (來源會複製到暫存位置,再移至目的地)。If tiles in the source and destination area of a Copy* operation have duplicated mappings in the copy area that would have overlapped even if both resources were not streaming resources and the Copy* operation supports overlapping copies, the Copy* operation will behave fine (as if the source is copied to a temporary location before going to the destination). 但如果重疊不明顯 (例如來源和目的地資源不同,但給定表面上的共用對應或對應重複),則不會定義共用磚上複製作業的結果。But if the overlap is not obvious (like the source and destination resources are different but share mappings or mappings are duplicated over a given surface), results of the copy operation on the tiles that are shared are undefined.

將複製到目的區域中的重複磚的資料流資源Copying to streaming resource with duplicated tiles in destination area

若複製到在目的地區域中有重複磚的串流資源,則會在這些磚中產生未定義的結果,除非資料本身相同。不同的磚可能會以不同的順序寫入磚。Copying to a streaming resource with duplicated tiles in the destination area produces undefined results in these tiles unless the data itself is identical; different tiles might write the tiles in different orders.

UAV 重複磚會存取對應UAV accesses to duplicate tiles mappings

假設串流資源上未排序的存取檢視 (UAV) 在其區域有重複磚對應,或有與其他管線繫結的資源。Suppose an unordered access view (UAV) on a streaming resource has duplicate tile mappings in its area or with other resources bound to the pipeline. 若由不同執行緒則執行,則不會定義這些重複磚的存取順序,就像任何 UAV 記憶體存取的順序通常都未排序。Ordering of accesses to these duplicated tiles is undefined if performed by different threads, just as any ordering of memory access to UAVs in general is unordered.

轉譯圖格對應變更或從外部對應的內容更新之後Rendering after tile mapping changes or content updates from outside mappings

如果資料流資源的圖格對應已變更,或在對應的並排顯示集區並排顯示的內容已變更透過另一個資料流資源的對應和資料流的資源,是要透過轉譯呈現目標檢視或深度樣板檢視,應用程式必須清除 (使用 fixed 的函數清楚的 Api),或透過使用複製完整複製*/更新*Api 呈現已變更區域內的圖格 (或未對應)。If a streaming resource's tile mappings have changed or content in mapped tiled pool tiles have changed via another streaming resource's mappings, and the streaming resource is going to be rendered via render target view or depth stencil view, the application must Clear (using the fixed function Clear APIs) or fully copy over using Copy*/Update* APIs the tiles that have changed within the area being rendered (mapped or not).

若應用程式無法在這些案例中進行清除或複製,則給定轉譯目標檢視或深度樣板檢視的硬體最佳化結構會過時,且會導致某些硬體上的廢棄項目轉譯結果,以及其他硬體間的不一致。Failure of an application to clear or copy in these cases results in hardware optimization structures for the given render target view or depth stencil view being stale, and will result in garbage rendering results on some hardware and inconsistency across different hardware. 硬體所使用的這些隱藏的最佳化資料結構可能對個別對應而言為本機項目,而不會對其他記憶體相同的對應顯示。These hidden optimization data structures used by hardware might be local to individual mappings and not visible to other mappings to the same memory.

當您清除資源檢視 (將資源檢視中的所有項目都設為一個值) 時,您可以清除具備矩形的轉譯目標檢視。When you clear a resource view (setting all the elements in a resource view to one value), you can clear render target views with rectangles. 若為支援串流資源的硬體,清除資源檢視必須也支援為僅限深度的表面 (不含樣板) 清除具備矩形的深度樣板檢視。For hardware that supports streaming resources, clearing a resource view must also support clearing of depth stencil views with rectangles, for depth only surfaces (without stencil). 這項作業可讓應用程式只清除表面的必要區域。This operation allows applications to clear only the necessary area of a surface.

若應用程式需要保留串流資源中區域現有的記憶體內容,其中該串流資源的對應已變更,則該應用程式必須針對清楚的需求採取因應措施。If an application needs to preserve existing memory contents of areas in a streaming resource where mappings have changed, that application must work around the clear requirement. 若應用程式要完成此因應措施,可以先儲存磚對應已變更的內容 (方法是將其複製到暫存表面)、發行需要的清除命令,然後再將內容複製回去。The application can accomplish this work-around by first saving the contents where tile mappings have changed (by copying them to a temporary surface), issuing the required clear command, and then copying the contents back. 雖然這可完成為遞增轉譯保存表面內容的工作,但缺點是表面的後續轉譯效能可能效能降低,因為轉譯最佳化可能遺失。While this would accomplish the task of preserving surface contents for incremental rendering, the downside is that subsequent rendering performance on the surface might suffer because rendering optimizations might be lost.

如果磚同時對應至多個串流資源,且透過其中一個串流資源以任何方式 (轉譯、複製等等) 操作磚內容,則如果同一個磚即將透過任何其他串流資源進行轉譯,該磚就必須如上文所述進行清除。If a tile is mapped into multiple streaming resources at the same time and tile contents are manipulated by any means (render, copy, and so on) via one of the streaming resources, if the same tile is to be rendered via any other streaming resource, the tile must be cleared first as previously described.

外部共用的圖格的轉譯呈現區域Rendering to tiles shared outside render area

假設串流資源的區域為轉譯目標,且轉譯區域所參考的磚集區磚也在轉譯區域外部為對應目標 (包括透過其他串流資源,同時或不同時)。Suppose an area in a streaming resource is being rendered to and the tile pool tiles referenced by the render area are also mapped to from outside the render area (including via other streaming resources, at the same time or not). 透過其他對應檢視時,轉譯至這些磚的資料並不保證會正確顯示,即使基礎記憶體配置相容也一樣。Data rendered to these tiles isn't guaranteed to appear correctly when viewed through the other mappings, even though the underlying memory layout is compatible. 這是因為某些硬體所使用的最佳化資料結構對可轉譯表面的個別對應而言可能為本機,但不會對記憶體位置相同的其他對應顯示。This fact is due to optimization data structures some hardware use that can be local to individual mappings for renderable surfaces and not visible to other mappings to the same memory location.

您可以從轉譯對應複製到所有其他可能存取之記憶體相同的對應 (或者若不再需要舊的內容,即可清除該記憶體或將其他資料複製到其中) 來因應這項限制。You can work around this restriction by copying from the rendered mapping to all the other mappings to the same memory that might be accessed (or clearing that memory or copying other data to it if the old contents are no longer needed). 雖然這項因應措施看起來很冗餘,但可讓所有其他記憶體相同的對應正確了解如何存取其內容,且至少因為只有單一實體記憶體備份保持不變而節省記憶體。While this work-around seems redundant, it makes all other mappings to the same memory correctly understand how to access its contents, and at least the memory savings of having only a single physical memory backing remains intact.

同時,當您使用共用對應的不同串流資源在之間切換時 (除非僅限讀取),您必須在切換之間於多個並列資源之間指定資料存取順序限制 (障礙)。Also, when you switch between using different streaming resources that share mappings (unless only reading), you must specify a data access ordering constraint (a barrier) between multiple tiled resources, in between the switches.

轉譯為共用轉譯區域內的圖格Rendering to tiles shared within render area

如果串流資源的區域為轉譯目標,且在轉譯區域中多個磚對應至相同的磚集區位置,則轉譯結果在該類磚上不會定義。If an area in a streaming resource is being rendered to and within the render area multiple tiles are mapped to the same tile pool location, rendering results are undefined on those tiles.

在共用磚的資源資料流處理的資料相容性Data compatibility across streaming resources sharing tiles

假設多個串流資源對應至相同的磚集區位置,且各個資源皆用來存取相同的資料。Suppose multiple streaming resources have mappings to the same tile pool locations and each resource is used to access the same data. 本案例只在以下情況才有效:避免其他關於避免硬體最佳化結構問題的規則、已指定適當障礙 (在多個並行資源之間指定資料存取順序限制),且串流資源彼此相容。This scenario is only valid if the other rules about avoiding problems with hardware optimization structures are avoided, appropriate barriers are specified (specifying a data access ordering constraint between multiple tiled resources), and the streaming resources are compatible with each other.

後者於此說明,內容關於串流資源共用磚不相容的意義。The latter is described here in terms of what it means for streaming resources sharing tiles to be incompatible. 存取重複磚對應之間相同資料的不相容情況是使用不同的表面維度或格式,或是資源上轉譯目標或深度樣板繫結旗標呈現的差異。The incompatibility conditions of accessing the same data across duplicate tile mappings are the use of different surface dimensions or format, or differences in the presence of render target or depth stencil bind flags on the resources. 若您後續透過來自不相容資源的對應進行讀取或轉譯,則使用一種對應寫入記憶體會產生未定義的結果。Writing to the memory with one type of mapping produces undefined results if you subsequently read or render via a mapping from an incompatible resource.

若另一個資源共用對應首先使用新資料初始化 (回收記憶體作為其他用途),則後續讀取或轉譯作業會運作正常,因為資料不會在不相容的解譯間洩出。If the other resource sharing mappings are first initialized with new data (recycling the memory for a different purpose), the subsequent read or render operation is fine since data isn't bleeding across incompatible interpretations. 不過,當您像這樣在存取不相容的對應間切換時,您必須指定障礙 (在多個並排資源間指定資料存取順序限制)。But, when you switch between accessing incompatible mappings like this, you must specify barriers (specifying a data access ordering constraint between multiple tiled resources).

如果在任何資源共用對應上彼此都未設定轉譯目標或深度樣板繫結旗標,則限制大為降低。If the render target or depth stencil bind flag isn't set on any of the resources sharing mappings with each other, there are far fewer restrictions. 只要格式及表面類型 (例如 Texture2D) 相同,即可共用磚。As long as the format and surface types (for example, Texture2D) are the same, tiles can be shared. 不同相容的格式為情況下,例如 BC*介面和對等項目調整大小未壓縮的 32 位元或每個元件的格式,例如 BC6H 和 R32G32B32A32 的 16 位元。Different formats being compatible are cases such as BC* surfaces and the equivalent sized uncompressed 32 bit or 16 bit per component format, like BC6H and R32G32B32A32. 許多的 32 位元,每個項目格式可以是具有 R32 別名_*也 (R10G10B10A2_*,R8G8B8A8_*,B8G8R8A8_*,B8G8R8X8_ *,R16G16_*); 一律為非資料流資源允許此作業。Many 32 bit per element formats can be aliased with R32_* as well (R10G10B10A2_*, R8G8B8A8_*, B8G8R8A8_*,B8G8R8X8_*,R16G16_*); this operation has always been allowed for non-streaming resources.

如果格式相容且磚會填入純色,則壓縮與非壓縮磚之間的共用會運作良好。Sharing between packed and non-packed tiles is fine if the formats are compatible and the tiles are filled with solid color.

最後,如果資源共用磚對應之間唯一的共同點是其皆不具轉譯目標或深度樣板繫結旗標,則僅可安全地共用填入 0 的記憶體;對應會顯示為任何 0 針對給定資源格式定義的解碼目標 (通常僅為 0)。Finally, if nothing is common about the resources sharing tile mappings except that none have render target or depth stencil bind flags, only memory filled with 0 can be shared safely; the mapping will appear as whatever 0 decodes to for the definition of the given resource format (typically just 0).

相關主題Related topics

資料流資源的存取管線Pipeline access to streaming resources