• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Put these 3D graphics terms into relation for me

3 posts in this topic

I have last seriously worked with 3D graphics using Direct3D 9 and I'm now in the process of refreshing my knowledge for Direct3D 11. In D3D9 I already used shaders extensively and I understand the purpose and advantages of constant buffers in D3D11, but my mental map currently consists of some disconnected islands of which I'm not sure how they are properly arranged.

This is how I believe it fits together. Can someone rearrange the terms in this tree to how things actually are?

Graphics Pipeline
[indent=4]S0 ... S127[/indent]
[indent=3]ConstantBuffer 1[/indent]
[indent=3]ConstantBuffer 2[/indent]
[indent=3]Sampler 1[/indent]
[indent=3]Sampler 2[/indent]
[indent=3]Texture 1[/indent]
[indent=3]Texture 2[/indent]
[indent=2]<same here as in vertex shaders>[/indent]

So in words, shaders distinguish between constant buffers and resources (i.e. constant buffers are not resources). I base that assumption on the fact that HLSL lets you explicitly declare which register a constant buffer is in but not a sampler. Also on the fact that [font=courier new,courier,monospace]ID3D11DeviceContext::PSSetConstantBuffers()[/font] and [font=courier new,courier,monospace]ID3D11DeviceContext::PSSetShaderResources()[/font] are separate methods and I've seen examples assigning a constant buffer to [i]constant buffer slot 0[/i] and a texture to [i]resource slot 0[/i].

And I assume shader registers (S0 ... S127) are the same thing [font=courier new,courier,monospace]ID3D11DeviceContext::PSSetConstantBuffers()[/font] assigns. What happens when I load a pre-SM4.0 shader? Is a constant buffer implicitly created for the parameters it declares? Or can registers hold either a constant buffer or a variable (though I can't find any way to access registers or variables directly in the D3D11 API). Edited by Cygon

Share this post

Link to post
Share on other sites
There are no separate 'constant registers' and 'constant buffers'. All constant variables are assigned into some constant buffer, either explicitly my the shader author, or automatically by the shader compiler. All constant variables outside any constant buffers go into a global $Global constant buffer. From http://msdn.microsoft.com/en-us/library/windows/desktop/bb509581(v=vs.85).aspx : "There are two default constant buffers available, $Global and $Param. Variables that are placed in the global scope are added implicitly to the $Global cbuffer, using the same packing method that is used for cbuffers."

The layout inside a Constant Buffer consists of a list of Constant Registers, each of which are 4xfloat vectors, and the variables in each Constant Buffer are laid out to these Constant Registers.

Textures and Texture Samplers are separate from Constant Buffer Slots, and these three are all assigned separately.

Share this post

Link to post
Share on other sites
In D3D9, each shader stage (pixel/vertex) has ~16 [font=courier new,courier,monospace]s[/font] registers, which hold both a texture pointer and a sampler state, and 256+ [font=courier new,courier,monospace]c[/font] registers, which hold a 16-byte [i]constant[/i] value ([i]e.g. a float4, one row of a matrix, one float with padding[/i]).
Also, on early D3D9 cards ([i]or on D3D11's "DX9 feature level"[/i]), the [font=courier new,courier,monospace]s[/font] registers can't be used in vertex shaders.

in D3D11, each shader stage has: [font=courier new,courier,monospace]s[/font] registers for sampler states, [font=courier new,courier,monospace]t[/font] registers for texture pointers, [font=comic sans ms,cursive]b[/font] registers for constant buffers, and [font=courier new,courier,monospace]u[/font] registers for UAV pointers.
The [font=courier new,courier,monospace]c[/font] registers are basically gone, and instead it's as if the [font=courier new,courier,monospace]b[/font] registers store (hidden) offsets into a huge amount of (hidden) [font=courier new,courier,monospace]c[/font] registers.

In HLSL, all of your variables (of all data types) [b]can[/b] use the register keyword to specify the mapping yourself, or you can reflect on the results of the shader compiler to discover the mapping, e.g. [font=courier new,courier,monospace]s3[/font] for the 4th sampler

When setting a value via the D3D API, the register index used will be used to look up the corresponding register file, so the [font=courier new,courier,monospace]b[/font] file if setting a [font=courier new,courier,monospace]cbuffer[/font] or the [font=courier new,courier,monospace]t[/font] file if setting a [font=courier new,courier,monospace]texture[/font]. Edited by Hodgman

Share this post

Link to post
Share on other sites
Constant buffers [i]are[/i] resources. They're just one type of resource, and there are several others. The two broad groups of resources are "Buffers" and "Textures", and there are various sub-types within those groups:

[*]Constant buffers - used for providing heterogeneous constant values to shaders, directly accessible by variable names. These are read-only in shaders, and cannot be access through a shader resource view.
[*]Buffers - provides an array of typed, homogeneous data to a shader, where the type comes from a DXGI_FORMAT.
[*]Structured buffers - provides an array of typed, homogeneous data to a shader, where the type is a user-defined structure.
[*]Byte-address buffers - also called raw buffers. Provides provides an array of raw data to a shader, where the data is accessed directly by byte offset and returned as a uint.
[*]Texture1D - one-dimensional texture, typed on a DXGI_FORMAT
[*]Texture1DArray - array of one dimensional textures
[*]Texture2D - two-dimensional texture, typed on a DXGI_FORMAT
[*]Texture2DArray - array of two-dimensional textures
[*]Texture3D - three-dimensional texture, typed on a DXGI_FORMAT

Constant buffers are special in that they can't be accessed through a shader resource view or an unordered access view, unlike the other buffer and texture types. Instead you bind them with *SSetConstantBuffers, and they're accessed by variable name in the shader. But otherwise they are the same as other buffer resources: you create them with CreateBuffer, you access their data with Map, and you can pass them to functions like CopyResource.

As for registers, there really aren't "registers" anymore you had with constant registers in D3D9 where they held numeric values. Instead the registers are really just "slots" that use as binding points for resources. This way the shader can say "hey I expect a Texture2D at slot 3", and the CPU can bind a shader resource view at slot with with *SSetShaderResources.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0