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

Unordered access view woes with non-structured buffers

7 posts in this topic

I've been trying to get this to work all morning, as far as I can tell I'm not doing anything obviously wrong. I cannot find any information about it but all examples I can find on using unordered access views are using structured buffers; may it be that they simply won't work with "normal" (primitive datatype) buffers?

 

Here's what I have:

// Buffer description
D3D11_BUFFER_DESC desc;
ZeroMemory(&desc, sizeof(D3D11_BUFFER_DESC));
desc.Usage		= D3D11_USAGE_DEFAULT;
desc.ByteWidth		= (UINT)cbByteSize;
desc.BindFlags		= D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;

// The above works for successfully creating a buffer without any warnings or errors, 
// some initial data is provided and a normal shader resource view can be created, 
// bound to and used by shaders without issues.
// However when I try to create another (unordered access) view for the same buffer 
// like so...

D3D11_UNORDERED_ACCESS_VIEW_DESC udesc;
ZeroMemory(&udesc, sizeof(D3D11_UNORDERED_ACCESS_VIEW_DESC));
udesc.Format			= srvDesc.Format; // This seems to be what causes trouble
udesc.ViewDimension		= D3D11_UAV_DIMENSION_BUFFER;
udesc.Buffer.FirstElement	= srvDesc.Buffer.FirstElement;
udesc.Buffer.NumElements	= srvDesc.Buffer.NumElements;

The debug layer tells me that "the format cannot be used with a typed unordered access view". It doesn't matter if I specify the same format as that which works with the shader resource view, the corresponding TYPELESS format or DXGI_FORMAT_UNKNOWN; I get the same error at all times.

What puzzles me is that it says "typed unordered access view". What does this mean? It sounds like it might be suggesting it is indeed expecting a structured buffer?

 

I'm posting this here in the hope that someone with more experience will be able to shed some more light on this.

0

Share this post


Link to post
Share on other sites
RWBuffer<float3> RWBuf : register(u0);

But it fails at the call to ID3D11Device::CreateUnorderedAccessView so I don't think the shader declaration is of any relevance since they haven't been bound together yet by then.

1

Share this post


Link to post
Share on other sites

Do you by any means have a render target bound?

 

If I'm not mistaken the UAVs and Render Target Views use the same "registry" (Perhaps a different word is used). As an example, if you had one render target, the UAV has to have an offset by 1.

struct PSOut
{
    float3 Diffuse : SV_Target0;
};

// RWBuffer<float3> RWBuf : register(u0); Wrong, the render target and UAV both use the same register

RWBuffer<float3> RWBuf : register(u1);

And if two render targets were bound, the UAV had to have an offset by 2. Or you can use your own packing method, just as long as they dont overlap.

 

Documentation on OMSetRenderTargetsAndUnorderedAccessViews: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476465(v=vs.85).aspx

  • UAVStartSlot [in]
  •                      >> For pixel shaders, UAVStartSlot should be equal to the number of render-target views being bound.

 

Although if no render targets are bound to register 0, this is irrelevant.

 

EDIT: "But it fails at the call to ID3D11Device::CreateUnorderedAccessView so I don't think the shader declaration is of any relevance since they haven't been bound together yet by then.", sorry, misread, this is irrelevant.

Edited by Migi0027
0

Share this post


Link to post
Share on other sites


If I'm not mistaken the UAVs and Render Target Views use the same "registry" (Perhaps a different word is used).

Ah yes, that limitation has caused quite some issues since my engine initially allowed binding render targets to arbitrary registers so that there could be unused ones (reserved for possible future use) in-between. I suppose that wasn't the best solution anyway, so good riddance in a way.

 

I've had some progress whereby it seems that the DXGIFORMAT_R32_UINT works, but that kind of takes away the notion that buffers can be of "any primitive type" so there is most likely something wrong here still... I'll try to get to the bottom of it tomorrow.

0

Share this post


Link to post
Share on other sites

It's been a long time, but I'm pretty sure that I've used UAV's with typed buffers of various formats in older projects. I will have to check when I get home. That said, I'm not sure where the issue is in your code. What format are you trying to use?

Edited by MJP
0

Share this post


Link to post
Share on other sites

Typed UAVs have some restrictions, check the DXGI programming guide under Hardware Support for Direct3D 11 Formats.

 

Column 22 on mine is Typed UAV, and it does apply to most of the types. Conspicuously absent from it, however, are 96-bit RGB, 64-bit depth/stencil, 32-bit depth (use R32), packed 24/8 depth/stencil, shared exponent and odd RG_BG/GR_GB modes, and all of the block compressed formats.
 

tl;dr: DXGI_FORMAT_R32G32B32_FLOAT doesn't work for typed UAVs. The rest do.

2

Share this post


Link to post
Share on other sites

Ah yes, I eventually reached the conclusion that it will in fact only work for "real" primitive datatypes (and probably no 64-bit ones like doubles either for that matter). I was led astray by a passage in Practical Rendering with DirectX 11 that insinuated that things like float3 were in fact considered primitives in HLSL and then the fact that the DXGI_FORMAT enumeration contain lots of formats that are indeed vectors. However I suppose they should be treated like syntactic sugar and indeed require a structured buffer.

 

Thanks for your input :)

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