X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=apps%2Fd3d11%2Ftri.cpp;h=fe746313c29902db72c01a187cbc319089f01233;hb=HEAD;hp=28f930298e2a30b45d0b442947cfb1f2c2ba77f9;hpb=5a26553410dc781b71da75c163400b801dfbf34a;p=apitrace-tests diff --git a/apps/d3d11/tri.cpp b/apps/d3d11/tri.cpp index 28f9302..fe74631 100644 --- a/apps/d3d11/tri.cpp +++ b/apps/d3d11/tri.cpp @@ -34,8 +34,8 @@ #include -#include "tri_vs.h" -#include "tri_ps.h" +#include "tri_vs_4_0.h" +#include "tri_ps_4_0.h" static IDXGISwapChain* g_pSwapChain = NULL; @@ -43,7 +43,9 @@ static ID3D11Device * g_pDevice = NULL; static ID3D11DeviceContext * g_pDeviceContext = NULL; -int main(int argc, char *argv[]){ +int +main(int argc, char *argv[]) +{ HRESULT hr; HINSTANCE hInstance = GetModuleHandle(NULL); @@ -89,10 +91,13 @@ int main(int argc, char *argv[]){ ShowWindow(hWnd, SW_SHOW); + UINT Flags = 0; + if (LoadLibraryA("d3d11sdklayers")) { + Flags |= D3D11_CREATE_DEVICE_DEBUG; + } + DXGI_SWAP_CHAIN_DESC SwapChainDesc; ZeroMemory(&SwapChainDesc, sizeof SwapChainDesc); - SwapChainDesc.BufferDesc.Width = WindowWidth; - SwapChainDesc.BufferDesc.Height = WindowHeight; SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;; SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60; SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1; @@ -102,6 +107,7 @@ int main(int argc, char *argv[]){ SwapChainDesc.BufferCount = 2; SwapChainDesc.OutputWindow = hWnd; SwapChainDesc.Windowed = true; + SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; static const D3D_FEATURE_LEVEL FeatureLevels[] = { D3D_FEATURE_LEVEL_11_0, @@ -112,7 +118,7 @@ int main(int argc, char *argv[]){ hr = D3D11CreateDeviceAndSwapChain(NULL, /* pAdapter */ D3D_DRIVER_TYPE_HARDWARE, NULL, /* Software */ - D3D11_CREATE_DEVICE_DEBUG, + Flags, FeatureLevels, sizeof FeatureLevels / sizeof FeatureLevels[0], D3D11_SDK_VERSION, @@ -131,7 +137,12 @@ int main(int argc, char *argv[]){ if (FAILED(hr)) { return 1; } - hr = g_pDevice->CreateRenderTargetView(pBackBuffer, NULL, &pRenderTargetView); + D3D11_RENDER_TARGET_VIEW_DESC RenderTargetViewDesc; + ZeroMemory(&RenderTargetViewDesc, sizeof RenderTargetViewDesc); + RenderTargetViewDesc.Format = SwapChainDesc.BufferDesc.Format; + RenderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + RenderTargetViewDesc.Texture2D.MipSlice = 0; + hr = g_pDevice->CreateRenderTargetView(pBackBuffer, &RenderTargetViewDesc, &pRenderTargetView); if (FAILED(hr)) { return 1; } @@ -222,8 +233,12 @@ int main(int argc, char *argv[]){ RasterizerDesc.CullMode = D3D11_CULL_NONE; RasterizerDesc.FillMode = D3D11_FILL_SOLID; RasterizerDesc.FrontCounterClockwise = true; + RasterizerDesc.DepthClipEnable = true; ID3D11RasterizerState* pRasterizerState = NULL; - g_pDevice->CreateRasterizerState(&RasterizerDesc, &pRasterizerState); + hr = g_pDevice->CreateRasterizerState(&RasterizerDesc, &pRasterizerState); + if (FAILED(hr)) { + return 1; + } g_pDeviceContext->RSSetState(pRasterizerState); g_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);