• 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
Meltac

Call hardware features from HLSL shader code

7 posts in this topic

Hello

Is it somehow possible to call the hardware-supported features of the respective DirectX version, such as volumetric light and fog in DX10, directly from a vertex or pixel shader using pure HLSL code? Or is the only way to do this with the "D3D..." API functions being called from the main program?

Thanks.
0

Share this post


Link to post
Share on other sites
"Volumetric light and fog" aren't hardware features of DX10 GPUs. There's no main-program API, nor HLSL intrinsic that maps to a 'feature' like that... You build advanced features (such as volumetric effects) out of the simpler features of the API/shaders.
2

Share this post


Link to post
Share on other sites
Thanks for the correction, but that was not very helpful. As you know very well every DirectX version brings a set of new or improved high-level methods to address low-level methods and GPU hardware features. Some hardware features that could not be addressed directly from a high-level API in a specific DirectX version thus needed to be done purely software-wise, can be addressed fairly simple in a subsequent DirectX version from the main app (as long as the GPU also supports that feature hardware-wise).

So forget about volumetric light and fog, please just tell me if it's possible to address what you call "simpler features" purely from within HLSL shader code, in order to "build advanced features", or if those features are only accessible by the D3D... or whatever API functions. Edited by Meltac
0

Share this post


Link to post
Share on other sites
[quote name='Meltac' timestamp='1343220880' post='4962917']every DirectX version brings a set of new or improved high-level methods to address low-level methods and GPU hardware features.[/quote]This is reflected by the different versions ([i]targets[/i]) of HLSL.

DX9 supports Shader Model 1/2/3. DX10 added Shader Model 4. DX11 added Shader Model 5.

e.g. HLSL code that's compiled against the ps_3_0 target can use intrinsic functions that didn't exist in ps_2_0, such as [font=courier new,courier,monospace][url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588(v=vs.85).aspx"]ddx[/url][/font].
or another example, DX11 GPU's added support for ps_5_0, which includes functions like [font=courier new,courier,monospace][url="http://msdn.microsoft.com/en-us/library/windows/desktop/ff471356(v=vs.85).aspx"]firstbitlow[/url][/font].
If you tried to use [font=courier new,courier,monospace]ddx[/font] or [font=courier new,courier,monospace]firstbitlow[/font] when compiling your shaders against the ps_2_0 target, you'll get a compile error.

If you compile against a higher target than your GPU supports ([i]e.g. you compile a shader against ps_5_0, and then try to use it on a DX10 GPU[/i]), then you'll get a D3D API error when trying to create the shader object from the compiled byte-code.

The MSDN pages for HLSL ([i]such as the links above[/i]) show you which targets support each intrinsic function. Edited by Hodgman
0

Share this post


Link to post
Share on other sites
Ok, but does that mean that a specific HLSL version / target / shader model provides access to exact the same feature set as the respective higher-level program API? For example, do I have access to the same GPU features from HLSL code compiled against Shader Model 5 / ps_5_0 as I would have when programming XNA / C++ / C# code against the DirectX11 high level API? Or are there any differences between what "simple features" are accessible from within HLSL or XNA functions on the same target?

(always under the condition that the underlying GPU supports the features in question) Edited by Meltac
0

Share this post


Link to post
Share on other sites
HLSL is just used to program GPU's, so they know how to fill a texture, etc.

1-You can't do anything using only HLSL!
2-You write a GPU program called shader in HLSL.
3-You set the correct render target, and textures needed by the shader using DirectX API and C++/C#.
4-You tell the GPU which shader to run using DirectX API and C++/C#.
5-You tell the GPU to execute the shader using DirectX API and C++/C#.

To create more advanced effects you do this multiple times.

Example (shadow mapping) (this is an extreme simplification):

(Application-side code = C++/C# + DirectX API - Executed in the GPU)
(GPU-side code =HLSL shader programs)

Application side:
-Bind the shadow map as the render target.
-Tell the GPU to use the shadow mapping HLSL shader.
-Make the draw calls of the scene geometry.

GPU side:
-The shadow mapping shader calculates the distance from the camera to the geometry vertices and stores it in the render target bound in the application side.

Application side:
-Bind the Back buffer as the render target (back buffer is the texture shown on your screen).
-Bind the shadow map as a shader resource (texture).
-Tell the GPU to use the final HLSL shader.
-Make the draw calls of the scene geometry.

GPU side:
-The shader calculates the color of the screen pixel using the shadow map bound in the application side and the geometry diffuse maps, etc.

ANYWAY: Without C++/C# + DirectX API you can't bind render targets, textures, tell the GPU what to do and when to do it, so HLSL shaders are useless. Edited by TiagoCosta
0

Share this post


Link to post
Share on other sites
[quote name='Meltac' timestamp='1343227949' post='4962946']
Ok, but does that mean that a specific HLSL version / target / shader model provides access to exact the same feature set as the respective higher-level program API? For example, do I have access to the same GPU features from HLSL code compiled against Shader Model 5 / ps_5_0 as I would have when programming XNA / C++ / C# code against the DirectX11 high level API? Or are there any differences between what "simple features" are accessible from within HLSL or XNA functions on the same target?

(always under the condition that the underlying GPU supports the features in question)
[/quote]

HLSL is part of the DirectX API, the two are intertwined. You use HLSL to author your shaders, and you use the API to bind your shaders, set up resources, issue draw calls, etc.

Just so you're clear, XNA is built on top of D3D9 and therefore doesn't have access to anything newer than shader 3.0. The other managed wrappers (SlimDX and SharpDX) fully expose D3D11, so you have access to everything you would in native D3D11 with C++.
0

Share this post


Link to post
Share on other sites
Ok, thanks everybody for the explanations. I think I got the idea now [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

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