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

WP8 Depth Buffer works in Emulator, not on the ARM device

0 posts in this topic

Hi all.

 

I'm trying to display a scene on windows phone 8 using D3D11. I got it to work without a Depth Buffer (using mostly Windows phone SDK sample). But now I actually need a depth buffer to render the scene correctly. I got it to work with a depth buffer on the Windows Phone Emulator (win32 build), but when I test it on any windows phone (ARM build), I get nothing (black screen).

 

So I must hit something that the graphic card on my computer understands (that is the only part of the windows phone emulator that is not fully emulated I think) but that the graphic card on the actual phone doesn't get.

 

Please if you have any idea let me know. Here is my code:

  UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

  D3D_FEATURE_LEVEL featureLevels[] = 
  {
    D3D_FEATURE_LEVEL_9_3
  };

  // Create the Direct3D 11 API device object and a corresponding context.
  ComPtr<ID3D11Device> device;
  ComPtr<ID3D11DeviceContext> context;
  ThrowIfFailed(
    D3D11CreateDevice(
    nullptr, // Specify nullptr to use the default adapter.
    D3D_DRIVER_TYPE_HARDWARE,
    nullptr,
    creationFlags, // Set set debug and Direct2D compatibility flags.
    featureLevels, // List of feature levels this app can support.
    ARRAYSIZE(featureLevels),
    D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION.
    &device, // Returns the Direct3D device created.
    &m_featureLevel, // Returns feature level of device created.
    &context // Returns the device immediate context.
    )
    );

  // Get the Direct3D 11.1 API device and context interfaces.
  ThrowIfFailed(
    device.As(&m_d3dDevice)
    );

  ThrowIfFailed(
    context.As(&m_d3dContext)
    );

 
 CD3D11_TEXTURE2D_DESC renderTargetDesc(
    DXGI_FORMAT_B8G8R8A8_UNORM,
    static_cast<UINT>(m_renderTargetSize.Width),
    static_cast<UINT>(m_renderTargetSize.Height),
    1,
    1,
    D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE
    );
  renderTargetDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;

  // Allocate a 2-D surface as the render target buffer.
  ThrowIfFailed(
    m_d3dDevice->CreateTexture2D(
    &renderTargetDesc,
    nullptr,
    &m_renderTarget
    )
    );

  ThrowIfFailed(
    m_d3dDevice->CreateRenderTargetView(
    m_renderTarget.Get(),
    nullptr,
    &m_renderTargetView
    )
    );
  
  // Create a depth stencil view.
 CD3D11_TEXTURE2D_DESC depthBufferDesc(
    DXGI_FORMAT_D24_UNORM_S8_UINT,
    static_cast<UINT>(m_renderTargetSize.Width),
    static_cast<UINT>(m_renderTargetSize.Height),
    1,
    1,
    D3D11_BIND_DEPTH_STENCIL); //tried with D3D11_BIND_RENDER_TARGET with a format DXGI_FORMAT_R24G8_TYPELESS in didn't change anything

  ThrowIfFailed(
    m_d3dDevice->CreateTexture2D(
    &depthBufferDesc,
    nullptr,
    &m_depthStencilBuffer
    )
    );

  D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
// Set up the description of the stencil state.
depthStencilDesc.DepthEnable = true;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;

depthStencilDesc.StencilEnable = true;
depthStencilDesc.StencilReadMask = 0xFF;
depthStencilDesc.StencilWriteMask = 0xFF;

// Stencil operations if pixel is front-facing.
depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

// Stencil operations if pixel is back-facing.
depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

  ThrowIfFailed(
    m_d3dDevice->CreateDepthStencilState(
    &depthStencilDesc,
    &m_depthStencilState
    )
    );

  m_d3dContext->OMSetDepthStencilState(m_depthStencilState.Get(), 1);
  
  CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
    D3D11_DSV_DIMENSION_TEXTURE2D, DXGI_FORMAT_D24_UNORM_S8_UINT, 0);
  ThrowIfFailed(
    m_d3dDevice->CreateDepthStencilView(
    m_depthStencilBuffer.Get(),
    &depthStencilViewDesc,
    &m_depthStencilView
    )
    );
  m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get());

  CD3D11_VIEWPORT viewport(
    0.0f,
    0.0f,
    m_renderTargetSize.Width,
    m_renderTargetSize.Height
    );

  m_d3dContext->RSSetViewports(1, &viewport);

... Before Draw ...
  
const float midnightBlue[] = { 245.0f/255.0f, 241.0/255.0f, 196.0f/255.0f, 1.000f };
	m_d3dContext->ClearRenderTargetView(
		m_renderTargetView.Get(),
		midnightBlue
		);

  m_d3dContext->ClearDepthStencilView(
        m_depthStencilView.Get(),
        D3D11_CLEAR_DEPTH,
        1.0f,
        0
        );

  m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get()); //This only works in the Emulator.
  //m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), nullptr); This works fine but doesn't use the Depth buffer, so the scene is not very good.
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