Jump to content

  • Log In with Google      Sign In   
  • Create Account

deks

Member Since 09 May 2000
Offline Last Active Nov 05 2014 01:05 PM

Topics I've Started

Free events viewer?

24 June 2010 - 07:16 AM

Hi.

I'm gathering huge amounts of events data in the form (event_name,start_cycle,end_cycle) in my game and I want to visualize it on a graph, something similar to VTune, Pix, etc. Before implementing this viewer, I was wondering if there was existing (free?) solutions out there.

Thanks!
JF

concept-mapping software

10 December 2008 - 01:21 AM

Hi. I'm looking for a free software that would let me enter personnal notes, with tags and easy searching, as simple as it can be: enter text, set tags, search by keywords, date, tags, etc. Nothing fancy-looking required... Any ideas? JF

Running 64-bits code in 32-bits mode?

12 August 2008 - 08:21 AM

Hi. I have a 64-bits enabled CPU, but I am running the 32-bits version of Vista. I want to do some testing with 32.32 fixed-point code I am implementing, and want to use 64-bits registers. Is there a way to test 64-bits code when the CPU is in 32-bits mode? Thanks, JF

Understanding polygon tiling with coverage masks

12 August 2008 - 08:17 AM

Hi. Following this post about Larrabee, I read the paper and became interested in their software rendering implementation. According to the paper, their algorithm is based on this paper. The way I understand it is the following: the frame starts with a single-node covering the whole screen. Then, for each triangle rendered, all the nodes intersecting with an edge of the triangle are recursively subdivided until they fits a single-pixel, leaving unsubdivided nodes inside the triangles. I am correct? It's not clear in the Larrabee paper, but it looks like they keep zmin and zmax for each node, so new triangles can be rejected in parts or totally based on the depth coverage. Isn't it what they call hierachical z-buffer? Thanks for any comments about this! JF

D3D10 basic problem -- source included

01 April 2008 - 07:33 AM

Hi. I just started playing with D3D10, trying to render a simple line. PIX reports that everything is in viewport, but still, nothing renders (depth/stencil tests and blending are disabled). Here's the complete code, if anyone's knows what's going on:
#include "stdafx.h"
#include "d3d10.h"
#include "d3dx10.h"
#include "testdx10.h"

#define MAX_LOADSTRING 100

const char shader[] = 
{
"struct VS_IN"
"{"
    "float2 position : POSITION;"
"};"
""
"struct VS_OUT"
"{"
    "float4 position : POSITION;"
"};"
""
"VS_OUT Vertex_Shader(const VS_IN v)"
"{"
    "VS_OUT o = (VS_OUT)0;"
    "o.position = float4(v.position, 0, 1);"
    "return o;"
"}"
""
"float4 Pixel_Shader(const VS_OUT v) : SV_Target"
"{"
    "return float4(1,1,1,1);"
"}"
};

// Global Variables:
HINSTANCE hInst;								// current instance
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name

// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int, HWND&);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_TESTDX10, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
    HWND WindowHandle;
	if (!InitInstance (hInstance, nCmdShow, WindowHandle))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TESTDX10));

    // Dx10 tests
    int Width;
    int Height;
    IDXGISwapChain* SwapChain;
    ID3D10Texture2D* BackBuffer;
    ID3D10RenderTargetView* RenderTargetView;

    RECT ClientRect;
    GetClientRect((HWND)WindowHandle, &ClientRect);
    Width = (ClientRect.right - ClientRect.left);
    Height = (ClientRect.bottom - ClientRect.top);

    DXGI_SWAP_CHAIN_DESC SwapChainDesc;
    ZeroMemory(&SwapChainDesc, sizeof(SwapChainDesc));

    SwapChainDesc.BufferCount = 1;
    SwapChainDesc.BufferDesc.Width = Width;
    SwapChainDesc.BufferDesc.Height = Height;
    SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
    SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;        
    SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    SwapChainDesc.OutputWindow = (HWND)WindowHandle;
    SwapChainDesc.SampleDesc.Count = 1;
    SwapChainDesc.SampleDesc.Quality = 0;
    SwapChainDesc.Windowed = TRUE;

    ID3D10Device* GD3DDevice = NULL;
    D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &SwapChainDesc, &SwapChain, &GD3DDevice);

    SwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&BackBuffer);
    GD3DDevice->CreateRenderTargetView(BackBuffer, 0, &RenderTargetView);
    BackBuffer->Release();
    
    GD3DDevice->OMSetRenderTargets(1, &RenderTargetView, NULL);

    struct cvertex
    {
        D3DXVECTOR2 position;
    };

    static ID3D10VertexShader* VertexShader = NULL;
    static ID3D10PixelShader* PixelShader = NULL;
    static ID3D10InputLayout* VertexLayout = NULL;
    static ID3D10Buffer* IndexBuffer = NULL;
    static ID3D10BlendState*       g_pBlendStateNoBlend = NULL;
    static ID3D10RasterizerState*	g_pRasterizerStateNoCull = NULL;
    static ID3D10Buffer* VertexBuffer = NULL;
    static ID3D10DepthStencilState* DepthStencilState = NULL;

    UINT CompileShaderFlags = 0;

    ID3D10Blob* Shader = NULL;
    ID3D10Blob* Errors = NULL;
    HRESULT Result = D3D10CompileShader(
        shader,
        strlen(shader),
        "",
        NULL,
        NULL,
        "Vertex_Shader",
        "vs_4_0",
        CompileShaderFlags,
        &Shader,
        &Errors
    );

    GD3DDevice->CreateVertexShader((void*)Shader->GetBufferPointer(), Shader->GetBufferSize(), &VertexShader);

    // Create our vertex input layout
    const D3D10_INPUT_ELEMENT_DESC layout[] =
    {
        { "POSITION",  0, DXGI_FORMAT_R32G32_FLOAT, 0, 0,  D3D10_INPUT_PER_VERTEX_DATA, 0 },
    };
    GD3DDevice->CreateInputLayout(layout, 1, Shader->GetBufferPointer(), Shader->GetBufferSize(), &VertexLayout);

    Shader->Release();

    Result = D3D10CompileShader(
        shader,
        strlen(shader),
        "",
        NULL,
        NULL,
        "Pixel_Shader",
        "ps_4_0",
        0,
        &Shader,
        &Errors
    );

    GD3DDevice->CreatePixelShader((void*)Shader->GetBufferPointer(), Shader->GetBufferSize(), &PixelShader);
    Shader->Release();

    // Create index buffer
    D3D10_BUFFER_DESC ibDesc;
    ibDesc.ByteWidth = 2 * sizeof(WORD);
    ibDesc.Usage = D3D10_USAGE_DEFAULT;
    ibDesc.BindFlags = D3D10_BIND_INDEX_BUFFER;
    ibDesc.CPUAccessFlags = 0;
    ibDesc.MiscFlags = 0;

    WORD IndexData[2] = { 0, 1 };
    D3D10_SUBRESOURCE_DATA ibInitData;
    ZeroMemory( &ibInitData, sizeof( D3D10_SUBRESOURCE_DATA ) );
    ibInitData.pSysMem = IndexData;
    GD3DDevice->CreateBuffer( &ibDesc, &ibInitData, &IndexBuffer );

    // Create a blend state to disable alpha blending
    D3D10_BLEND_DESC BlendState;
    ZeroMemory(&BlendState, sizeof(D3D10_BLEND_DESC));
    BlendState.BlendEnable[0] = FALSE;
    BlendState.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
    GD3DDevice->CreateBlendState(&BlendState, &g_pBlendStateNoBlend);

    // Create a rasterizer state to disable culling
    D3D10_RASTERIZER_DESC RSDesc;
    RSDesc.FillMode = D3D10_FILL_SOLID;
    RSDesc.CullMode = D3D10_CULL_NONE;
    RSDesc.FrontCounterClockwise = TRUE;
    RSDesc.DepthBias = 0;
    RSDesc.DepthBiasClamp = 0;
    RSDesc.SlopeScaledDepthBias = 0;
    RSDesc.DepthClipEnable = FALSE;
    RSDesc.ScissorEnable = FALSE;
    RSDesc.MultisampleEnable = FALSE;
    RSDesc.AntialiasedLineEnable = FALSE;
    GD3DDevice->CreateRasterizerState(&RSDesc, &g_pRasterizerStateNoCull);

    // Create dynamic vertex buffer
    D3D10_BUFFER_DESC vbDesc;
    vbDesc.ByteWidth = 4 * sizeof(cvertex);
    vbDesc.Usage = D3D10_USAGE_DEFAULT;
    vbDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
    vbDesc.CPUAccessFlags = 0;
    vbDesc.MiscFlags = 0;

    float X0 = 0.0f;
    float Y0 = 0.0f;
    float X1 = 1.0f;
    float Y1 = 1.0f;

    cvertex vertices[2] = { D3DXVECTOR2(X0, Y0), D3DXVECTOR2(X1, Y1) };
    D3D10_SUBRESOURCE_DATA vbInitData;
    ZeroMemory( &vbInitData, sizeof( D3D10_SUBRESOURCE_DATA ) );
    vbInitData.pSysMem = vertices;
    GD3DDevice->CreateBuffer( &vbDesc, &vbInitData, &VertexBuffer );

    D3D10_DEPTH_STENCIL_DESC DepthStencilDesc;
    ZeroMemory( &DepthStencilDesc, sizeof( D3D10_DEPTH_STENCIL_DESC ) );
    DepthStencilDesc.DepthFunc = D3D10_COMPARISON_ALWAYS;
    GD3DDevice->CreateDepthStencilState(&DepthStencilDesc, &DepthStencilState);

    GD3DDevice->OMSetDepthStencilState(DepthStencilState, 0);

    // Main message loop
    msg.message = 0;
	while(msg.message != WM_QUIT)
	{
        if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
		    if(!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		    {
    	        TranslateMessage(&msg);
	            DispatchMessage(&msg);
            }
        }
        else
        {
            float ClearColor[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
            GD3DDevice->ClearRenderTargetView(RenderTargetView, ClearColor);

            GD3DDevice->OMSetRenderTargets(1, &RenderTargetView, NULL);

            // Setup the viewport
            D3D10_VIEWPORT vp;
            vp.Width = Width;
            vp.Height = Height;
            vp.MinDepth = 0.0f;
            vp.MaxDepth = 1.0f;
            vp.TopLeftX = 0;
            vp.TopLeftY = 0;
            GD3DDevice->RSSetViewports( 1, &vp );

            // Set IA parameters
            UINT strides[1] = { sizeof( cvertex ) };
            UINT offsets[1] = {0};
            ID3D10Buffer* pBuffers[1] = { VertexBuffer };

            GD3DDevice->IASetVertexBuffers( 0, 1, pBuffers, strides, offsets );
            GD3DDevice->IASetInputLayout( VertexLayout );
            GD3DDevice->IASetIndexBuffer( IndexBuffer, DXGI_FORMAT_R16_UINT, 0 );
            GD3DDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_LINELIST );

            GD3DDevice->OMSetBlendState(g_pBlendStateNoBlend, 0, 0xffffffff);
            GD3DDevice->RSSetState(g_pRasterizerStateNoCull);
            GD3DDevice->VSSetShader( VertexShader );
            GD3DDevice->GSSetShader( NULL );
            GD3DDevice->PSSetShader( PixelShader ); 
            GD3DDevice->DrawIndexed( 2, 0, 0 );

            SwapChain->Present(0, 0);
        }
	}

	return (int) msg.wParam;
}

ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TESTDX10));
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_TESTDX10);
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

	return RegisterClassEx(&wcex);
}

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, HWND& hWnd)
{
   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code here...
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

Thanks in advance! JF

PARTNERS