Hardware Virtual Texturing

Slides:



Advertisements
Similar presentations
Using Matrices in Real Life
Advertisements

Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Chapter 6 Structures and Classes. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Learning Objectives Structures Structure types Structures.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
UNITED NATIONS Shipment Details Report – January 2006.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 10 second questions
Chapter 6 File Systems 6.1 Files 6.2 Directories
Solve Multi-step Equations
1 Chapter 10 - Structures, Unions, Bit Manipulations, and Enumerations Outline 10.1Introduction 10.2Structure Definitions 10.3Initializing Structures 10.4Accessing.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Chapter 5 : Memory Management
4.1 © 2004 Pearson Education, Inc. Exam Managing and Maintaining a Microsoft® Windows® Server 2003 Environment Lesson 4: Organizing a Disk for Data.
POST-PROCESSING SET09115 Intro Graphics Programming.
Data Structures ADT List
Chapter 24 Lists, Stacks, and Queues
Chapter 4 Memory Management Basic memory management Swapping
Data Structures Using C++
ABC Technology Project
Project 5: Virtual Memory
Multilevel Page Tables
Hash Tables.
Memory Management Unit
Reconstruction from Voxels (GATE-540)
2007 Pearson Education, Inc. All rights reserved C Structures, Unions, Bit Manipulations and Enumerations.
2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 10 - Structures, Unions, Bit Manipulations, and Enumerations Outline 10.1Introduction 10.2Structure.
Cache and Virtual Memory Replacement Algorithms
Module 10: Virtual Memory
Virtual Memory II Chapter 8.
Memory Management.
Chapter 15 Integrated Services Digital Network ISDN Services History Subscriber Access Layers BISDN WCB/McGraw-Hill The McGraw-Hill Companies, Inc., 1998.
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
VOORBLAD.
Name Convolutional codes Tomashevich Victor. Name- 2 - Introduction Convolutional codes map information to code bits sequentially by convolving a sequence.
Chapter 6 File Systems 6.1 Files 6.2 Directories
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
© 2012 National Heart Foundation of Australia. Slide 2.
Lecture plan Outline of DB design process Entity-relationship model
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
H to shape fully developed personality to shape fully developed personality for successful application in life for successful.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Januar MDMDFSSMDMDFSSS
Week 1.
SE-292 High Performance Computing
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Pointers and Arrays Chapter 12
PSSA Preparation.
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
Essential Cell Biology
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 30 - Dynamic HTML: Structured Graphics ActiveX Control Outline 30.1Introduction 30.2Shape Primitives.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2001 Chapter 16 Integrated Services Digital Network (ISDN)
Abstract Class, Packages and interface from Chapter 9
1 Abstract Class and Packages from Chapter 9 Lecture.
Data Structures Using C++ 2E
Partially Resident Textures on Next-Generation GPUs
Presentation transcript:

Hardware Virtual Texturing Graham Sellers, AMD graham.sellers@amd.com @grahamsellers

Hardware Virtual Texturing Virtual textures are textures that are not all in video memory at one time Software Virtual Textures (SVTs) have been around for a while The goal is to provide support in hardware

Virtual Textures Divide texture up into tiles Commit only used tiles to memory Store data in separate physical texture Physical Texture Virtual Texture

Virtual Textures Memory requirements set by number of resident tiles, not texture dimensions Virtual Physical Memory 4096 kB 1536 kB RGBA8, 1024x1024, 64 tiles

Virtual Textures Use indirection table to map virtual to physical This is also known as a page table

Virtual Textures Software Virtual Textures uniform sampler2D samplerPageTable; // page table texture uniform sampler2D samplerPhysTexture; // physical texture in vec4 virtUV; // virtual texture coordinates out vec4 color; // output color vec2 getPhysUV(vec4 pte); // translation function void main() { vec4 pte = texture(samplerPageTable, virtUV.xy); // (1) vec2 physUV = getPhysUV(pte); // (2) color = texture(samplerPhysTexture, physUV.xy); // (3) }

GPU Virtual Memory Virtual Memory for GPUs Very similar to virtual memory on CPUs Page tables in video memory Address translation handled by hardware

GPU Virtual Memory … texture(sampler, uv); uv data virtual address physical address Texture Unit virtual address data Memory Controller physical address data Physical Memory Page Table

Sparse Textures Paging The process of making resources resident in GPU-visible memory Handled by the operating system or lower level system components Non-sparse resources paged in and our with resource granularity

Sparse Textures Sparse textures depend on 3 core components: GPU virtual memory Shader core feedback Software driver stack

Sparse Textures and GPU Virtual Memory Texture Unit UV to virtual address translation Hardware filtering Cache Memory Controller Virtual to physical address translation Page table management

Virtual Textures Software Virtual Textures (Recap) uniform sampler2D samplerPageTable; // page table texture uniform sampler2D samplerPhysTexture; // physical texture in vec4 virtUV; // virtual texture coordinates out vec4 color; // output color vec2 getPhysUV(vec4 pte); // translation function void main() { vec4 pte = texture(samplerPageTable, virtUV.xy); // (1) vec2 physUV = getPhysUV(pte); // (2) color = texture(samplerPhysTexture, physUV.xy); // (3) }

Sparse Textures and GPU Virtual Memory Hardware Virtual Textures uniform sampler2D samplerPRT // partially-resident texture in vec4 virtUV; // virtual texture coordinates out vec4 color; // output color void main() { color = vec4(0.0); sparseTexture(samplerPRT, virtUV.xy, color); // (3) }

Sparse Textures and Shaders Virtual Address Space Segmented into 64KiB pages Each tile can be mapped (resident) or unmapped (non-resident) Mapping controlled by the driver and application x

Sparse Textures and Shaders texture(sampler, uv); … uv NACK virtual address Texture Unit NACK virtual address NACK Memory Controller Physical Memory Page Table

Sparse Allocations What can be sparse? Any tile-aligned region of a texture level

Sparse Allocations What can be sparse? Full mip-levels

Sparse Allocations What can be sparse? Cube map faces

Sparse Allocations What can be sparse? Any combination of the above, plus... Slices of 3D textures, array layers, etc., etc. ... so long as it meets tile alignment requirements

Sparse Textures and Shaders NACKs in shaders void main() { vec4 outColor = vec4(1.0, 1.0, 1.0, 1.0); int code = sparseTexture(sampler, texCoordVert.xy, outColor); if (sparseTexelResident(code)) // data resident gl_FragColor = vec4(outColor.rgb, 1.0); } else // NACK gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

Sparse Textures – Drivers Driver responsibilities Create and destroy sparse resources Map and un-map tiles Back virtual allocations with physical allocations

Sparse Textures – Drivers Backing storage A set of physical allocations containing texture data Don’t want one physical allocation per tile Driver manages pools of tiles Each application will have different requirements

Physical Texture Pools 1 2 3 x 16 17 18 19 12 13 14 15 8 9 10 11 20 21 22 23 28 29 30 31 4 5 6 7 24 25 26 27 Sparse Texture Chunk 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Chunk 2 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Physical Texture Pools 1 2 3 x 8 9 10 11 x 16 17 18 19 x 20 21 22 23 x 12 13 14 15 x 28 29 30 31 x x x x x x x x x x x 4 5 6 7 x x x x x x x x x x x x x 24 25 x x x x x x x x 26 27 x x x x x x x x x x x Sparse Texture Chunk 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Chunk 2 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 x x x x

Tile Pool Management Let the application deal with it! Introduce new objects called tile pools Non-virtual allocations Huge arrays of tiles Look like array textures Application gets to ‘place’ tiles into textures

Tile Pool Management Tile pools enable several things Tight, application controlled memory management Aliases – using the same tile at multiple places Sharing a single pool amongst many virtual textures Wang tiles in hardware

Hardware Virtual Textures Summary SVTs HVTs Address translation Shader code HW page table Filtering HW + shader code HW only # of texture fetches 2, dependent 1 Supported formats The ones implemented All supported by HW Supported texture types

Accessing the Feature Exposed through OpenGL extensions GL_AMD_sparse_texture Enables basic driver managed virtual textures GL_AMD_texture_tile_pool Adds tile pool support Still in the pipeline...

Sparse Textures in OpenGL Use of immutable texture storage Existing OpenGL immutable storage API Declare storage, specify image data GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexStorage2D(GL_TEXTURE_2D, 10, GL_RGBA8, 1024, 1024); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1024, 1024, GL_RGBA, GL_UNSIGNED_BYTE, data);

Sparse Textures in OpenGL Use of sparse texture storage glTexStorageSparseAMD is a new function GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexStorageSparseAMD(GL_TEXTURE_2D, GL_RGBA, 1024, 1024, 1, 1, GL_TEXTURE_STORAGE_SPARSE_BIT_AMD); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1024, 1024, GL_RGBA, GL_UNSIGNED_BYTE, data);

Sparse Textures in OpenGL Previous example uses glTexSubImage2D Driver allocates storage on demand Manages physical tile pools for application Pass NULL to glTexSubImage*D to de-allocate Advantages and disadvantages: Pros: simple, easy to integrate, backwards compatible Cons: not much control, driver overhead, etc. glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

OpenGL Texture Tile Pools Application control of tile pools Created new texture targets: GL_TEXTURE_1D_TILE_POOL GL_TEXTURE_2D_TILE_POOL GL_TEXTURE_3D_TILE_POOL These resemble array textures Fixed element size, unlimited elements Cannot directly texture from or render to them 3D = 3D ‘array’, which otherwise isn’t supported

OpenGL Texture Tile Pools Steps to using tile pools: Create texture using pool target Allocate storage as if it were an array texture Associate pool tiles with virtual textures

OpenGL Texture Tile Pools Create a tile pool Set properties of pool Select the type of pool (1D, 2D, 3D) Select internal format and tile size Set the number of tiles GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D_TILE_POOL, tex); glTexStoragePoolAMD(GL_TEXTURE_2D_TILE_POOL, // Type of pool GL_RGBA8, // Internal format 0, // Tile size index 10000); // Number of tiles

OpenGL Texture Tile Pools Put data in pools 2D tile pool looks like 2D array texture Manipulate pools directly using views glTexSubImage3D(GL_TEXTURE_2D_TILE_POOL, 0, 0, 0, tile, 256, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, data); glTextureView(tex, GL_TEXTURE_2D_ARRAY, // Create 2D array texture view pool, // from this pool GL_RGBA8, // in this format 0, 1, // with no mipmaps 9000, 1000); // from tile 9000 for 1000 tiles

OpenGL Texture Tile Pools Map pool tiles into textures Specify an array of tiles to map Each has an x, y, z offset and an index glTexTilePlacementAMD(GL_TEXTURE_2D, // Target 0, // Level 100, // Tile count xoffsets, yoffsets, zoffsets, // Arrays of offsets pool, // Pool object tileindices); // Indices of tiles

Sparse Textures in Shaders First and foremost IT IS NOT NECESSARY TO MAKE SHADER CHANGES TO USE SPARSE TEXTURES

Extending GLSL – Samplers Texture type in GLSL is the ‘sampler’ Several types of samplers exist... sampler2D, sampler3D, samplerCUBE, sampler2DArray, etc. We didn’t add any new sampler types Sparse textures look like regular textures in shaders

Reading from Textures Read textures using ‘texture’ Built-in function with several overloads: gvec4 texture(gsampler1D sampler, float P [, float bias]); gvec4 texture(gsampler2D sampler, vec2 P [, float bias]); gvec4 texture(gsampler2DArray sampler, vec3 P [, float bias]); gvec4 textureLod(gsampler2D sampler, vec2 P, float lod); gvec4 textureProj(gsampler2D sampler, vec4 P [, float bias]); gvec4 textureOffset(gsampler2D sampler, vec2 P, ivec2 offset [, float bias]); // ... etc.

Extending GLSL Added new built-in functions Return residency information along with data Most texture functions have a sparse version Mix-and match is possible: Non-sparse (ordinary) textures appear fully resident Sparse textures return undefined data in unmapped regions int sparseTexture(gsampler2D sampler, vec2 P, inout gvec4 texel [, float bias]); int sparseTextureLod(gsampler2D sampler, vec2 P, float lod, inout gvec4 texel); // ... etc.

Extending GLSL | Sparse Texture sparseTexture returns two pieces of data: Residency status code Texel data via inout parameter int sparseTexture(gsampler2D sampler, vec2 P, inout gvec4 texel [, float bias]);

Extending GLSL | Sparse Texture Texel data is returned via inout parameter If texel fetch fails, original value is retained This is like a CMOV operation Return code is hardware dependent Encodes residency information New built-in functions to decode it

Extending GLSL | Sparse Texture Residency information returned from fetch New built-in functions decode it vec4 texel = vec4(1.0, 0.0, 0.7, 1.0); // Default value int code; code = sparseTexture(s, texCoord, texel); bool sparseTexelResident(int code); bool sparseTexelMinLodWarning(int code); int sparseTexelLodWarningFetch(int code);

Extending GLSL | Sparse Texture Was texel resident? Texel miss is generated if any required sample is not resident, including: Texels required for bilinear or trilinear sampling Missing mip maps, anisotropic filter taps, etc. bool sparseTexelResident(int code);

Sparse Textures – Use Cases Drop-in replacement for traditional SVT Almost... maximum texture size hasn’t grown Extremely large texture arrays Only populate a sub-set of the slices Can eliminate texture binds in some applications

Sparse Textures – Use Cases Large volume textures Voxels, medical applications Distance fields + raymarching Use maximum step size as ‘default’ value Variable size texture arrays Create a large array texture Populate different mip levels in each slice

Sparse Textures – ARB Extension The OpenGL ARB adopted sparse textures Recent development – released this week Slightly different semantics Smaller feature set

Sparse Textures – ARB Extension ARB version of sparse texture Uses texture params + glTexStorage No new API No shader support No tile pool support Page sizes queryable Uses glGetInternalformativ Able to expose more than one selectable page size

Sparse Textures – Future Work Increase maximum texture size Finer control over edge effects Better residency feedback Standardize tile shapes

Thanks!