]> git.cworth.org Git - apitrace-tests/blobdiff - apps/d3d11/tri.cpp
Add d3d8 scnapshot. Be consistent with swapeffect.
[apitrace-tests] / apps / d3d11 / tri.cpp
index 1649bbf67d304da28c7e234239a0cfb3d7e5010c..2227b811667c9a2087b4fbca4cbb76b704dd4b22 100644 (file)
@@ -34,8 +34,8 @@
 
 #include <d3d11.h>
 
-#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,6 +91,11 @@ 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;
@@ -102,13 +109,20 @@ 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,
+        D3D_FEATURE_LEVEL_10_1,
+        D3D_FEATURE_LEVEL_10_0
+    };
 
     hr = D3D11CreateDeviceAndSwapChain(NULL, /* pAdapter */
                                        D3D_DRIVER_TYPE_HARDWARE,
                                        NULL, /* Software */
-                                       D3D11_CREATE_DEVICE_DEBUG,
-                                       NULL,
-                                       0,
+                                       Flags,
+                                       FeatureLevels,
+                                       sizeof FeatureLevels / sizeof FeatureLevels[0],
                                        D3D11_SDK_VERSION,
                                        &SwapChainDesc,
                                        &g_pSwapChain,
@@ -125,7 +139,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;
     }
@@ -216,8 +235,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);
@@ -250,6 +273,9 @@ int main(int argc, char *argv[]){
     g_pSwapChain->Release();
     g_pSwapChain = NULL;
 
+    g_pDeviceContext->Release();
+    g_pDeviceContext = NULL;
+
     g_pDevice->Release();
     g_pDevice = NULL;