• Advertisement
Sign in to follow this  

HAL not available?

This topic is 4302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whenever I call CreateDevice, it returns D3DERR_NOTAVAILABLE. I'm guessing it has something to do with the D3DDEVTYPE_HAL parameter, because HAL doesn't show up in the D3D Cps Viewer Utility, only a folder for Reference, although there is a bit of text about a D3D HAL driver in the DirectX portion in the Control Panel, and the box "Enable Hardware Accelerating" is checked. Here is my CreateDevice function: D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &Device); And here are my D3D Present Parameters: d3dpp.Windowed=TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; I'm using the February 2006 SDK. If anyone could tell me why this isn't working, I'd greatly appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
If HAL doesn't show up in the caps viewer, then it could indicate one of a few things:

1) The driver for your graphics card is too old to be recognised by newer versions of Direct3D. You'll need at least DirectX 6 level drivers for newer versions of D3D to see the HAL of the card.

2) DirectX isn't properly installed or has somehow become broken.

3) The "Hardware acceleration" slider in the Advanced section of your Display Properties is set to None.

4) Some other part of your Windows installation has somehow become broken (including manually installed/maintained drivers and bad drivers for system components like PCI routing).

5) The drivers for your graphics card are broken/incorrectly installed.

6) You have an old (or laptop) multi monitor configuration on your machine and/or that configuration has become broken. Some multimonitor configurations show up as multiple HAL's - when broken/old, one of those has no usable features.

7) a bad BIOS setting causing problems for your graphics card (interrupts, port mapping ranges, AGP aperture size, etc - all can provide hours of 'fun' if incorrectly set).


Try running DXDIAG (type DXDIAG into Start->Run...)and run all the tests for the display adapter(s) in the system, that will give you a better idea of what DirectX /really/ thinks is installed in your system.

If DXDIAG still thinks you have no hardware devices, first check the obvious things above, then try re-installing DirectX and the drivers for your graphics hardware.

Share this post


Link to post
Share on other sites
I updated the drivers for my video card, so DXDIAG runs all of its D3D tests perfectly, the SDK Samples no longer display a dialog about switching to REF, and HAL appears in the D3D Caps Viewer. However, my CreateDevice function is now returning D3D_INVALIDCALLL. The SDK samples all use DXUT, so it's hard to tell how they are calling CreateDevice. The syntax of my CreateDevice function hasn't changed, nor have my D3D Present Parameters. If anyone could explain the meaning of this error, I'd greatly appreciate it.

Share this post


Link to post
Share on other sites
Is it not outputting any error info along with it? For me, directx would usually spit out a more specific problem in the output window of visual studio.

Share this post


Link to post
Share on other sites
Your presentation parameter list seems incomplete. Is this all you have, or did you not post all of it?

I'm not sure if they are required, but I think it'll be a good idea to specify the backbuffer height and width, as a minimum. I'd also specify the AutoDepthStencilEnable value, and the AutoDepthStencil format, even if this isn't used (as someone here said recently).
If it's still failing, I'd specify as many of the values as I could, just to be sure I wasn't missing anything.

Hoep this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by programwizard
The SDK samples all use DXUT, so it's hard to tell how they are calling CreateDevice.
Try looking at the six tutorials (in the Samples\tutorials\ folder) rather than the actual samples. D3D9 tutorials don't use DXUT, so you can see the "pure" function calls...

hth
Jack

Share this post


Link to post
Share on other sites
I saw those tutorials, they use the same PP's as I am using. Could there be a problem in how I am creating a window?

Yes, I am using ZeroMemory.

No, the error message isn't very complete. I'm not doing a whole lot to error check; all I have is is the function returns INVALIDCALL, the program quits.

I'll try specifying BackBufferWidth and Height.

Share this post


Link to post
Share on other sites
My Present Parameters now look as such:

D3DPRESENT_PARAMETERS d3dpp;

ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed=TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat=D3DFMT_UNKNOWN;
d3dpp.BackBufferCount=1;
d3dpp.BackBufferHeight=0;
d3dpp.BackBufferWidth=0;

I'm not sure if any of these are correct for a HAL device, but these are the exact same parameters used by the D3D tutorials in the SDK. However, I'm still getting an INVALIDCALL.

I have a breakpoint right before the CreateDevice function, but after the pp's are created. While debugging, it informs me that d3dpp.BackBufferFormat is D3DFMT_X8R8G8B8, even though it's clearly being set to D3DFMT_UNKNOWN. Could this be the problem?

Share this post


Link to post
Share on other sites
Quote:
Original post by programwizard
I'm not sure if any of these are correct for a HAL device, but these are the exact same parameters used by the D3D tutorials in the SDK. However, I'm still getting an INVALIDCALL.


Whenever Direct3D returns an error such as D3DERR_INVALIDCALL, it usually tells you **why** in the debug output stream.
1) Link with d3d9d.lib and d3dx9d.lib (notice the d's).
2) run your program in the debugger (press F5 in MSVC).
3) when D3D returns the error, look at the "Output" window/tab in the IDE.
4) some more explanation for the error will be there.

Since your presentation parameters and other flags look ok, a problem with the window handle you're passing is the next thing I suspect - the debug output should tell us more.

Quote:
I have a breakpoint right before the CreateDevice function, but after the pp's are created. While debugging, it informs me that d3dpp.BackBufferFormat is D3DFMT_X8R8G8B8, even though it's clearly being set to D3DFMT_UNKNOWN. Could this be the problem?


Specifying D3DFMT_UNKNOWN is valid when Windowed is TRUE - it simply means "please use the same format as the desktop". CreateDevice() can and will modify members of the D3DPRESENT_PARAMETERS structure you passed to it. It's likely doing that with the format - replacing the UNKNOWN with the current known format.

Share this post


Link to post
Share on other sites
Strangely, I can link with d3dx9d.lib fine, but the file d3d9d.lib is completely missing from my computer (I just searched the whole C drive). I'll keep debugging to see if I can find out what is wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by programwizard
Strangely, I can link with d3dx9d.lib fine, but the file d3d9d.lib is completely missing from my computer (I just searched the whole C drive). I'll keep debugging to see if I can find out what is wrong.


Arrghh, my bad! - guess I killed a few too many braincells after work last night - link with d3d9.lib and you'll be fine, you won't find d3d9d.lib on your machine.

d3d9d.lib exists in the world...just not for Windows [wink]

The difference between the debug and retail D3D libraries is controlled in the DirectX control panel applet - in the Direct3D tab, select Use Debug Version of Direct3D and set the Debug Output Level slider to more than Less.

Share this post


Link to post
Share on other sites
OK, I've got D3D Debugging on, and it's now giving me the message "neither hDeviceWindow or Focus is set. CreateDevice failed". I'm setting hDeviceWindow to hWnd, but it still says it is unset, and the Locals window in the debugger (the window where you check the status of your variables) says the d3dpp.hDeviceWindow "cannot be evaluated". hWnd is a global variable, and CreateDevice is being called after hWnd is intialized with the window. This is a windowed application; any ideas?

Share this post


Link to post
Share on other sites
Could you possibly be missing some step in creating the window? Could you post the code to that?

Also, have you tried specifying the BackBufferHeight and BackBufferWidth explicitly?

Hope this helps.

Share this post


Link to post
Share on other sites
Here's everything:


// D3D_Test.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "D3D_Test.h"
#include <D3d9.h>

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
LPDIRECT3D9 D3D=NULL; //Main Direct3D object
LPDIRECT3DDEVICE9 Device=NULL; //Device used for rendering
HWND hWnd; //Window handle
MSG msg; //Message structure

// 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_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int InitDirect3D(LPDIRECT3D9, LPDIRECT3DDEVICE9, HWND);
void Render(LPDIRECT3DDEVICE9);
void Cleanup();

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

// TODO: Place code here.
HACCEL hAccelTable;

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

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

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

//Initialize Direct3D
InitDirect3D(D3D, Device, hWnd);

// Main message loop:
while (msg.message!=WM_QUIT)
{
if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{

if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
Render(Device);
}
}



return (int) msg.wParam;
}



//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
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_D3D_TEST));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_D3D_TEST);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);
}

//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
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;
}

//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
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_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
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:
Cleanup();
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}

//Direct3D initialization function
int InitDirect3D(LPDIRECT3D9 D3D, LPDIRECT3DDEVICE9 Device, HWND hWnd)
{
D3D=Direct3DCreate9(D3D_SDK_VERSION);
if (D3D==NULL)
{
msg.message=WM_QUIT;
}

D3DPRESENT_PARAMETERS d3dpp;

ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed=TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat=D3DFMT_UNKNOWN;
d3dpp.BackBufferCount=1;
d3dpp.BackBufferHeight=0;
d3dpp.BackBufferWidth=0;
d3dpp.hDeviceWindow=hWnd;

if (D3DERR_INVALIDCALL==D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &Device))
{
return E_FAIL;
}

if (hWnd==NULL)
{
msg.message=WM_QUIT;
}

return 1;
}

//Draw everything
void Render(LPDIRECT3DDEVICE9 Device)
{
Device->BeginScene();
Device->EndScene();
}

//Cleanup function
void Cleanup()
{
if (D3D!=NULL)
D3D->Release();
if (Device!=NULL)
Device->Release();
}


Most of it was generated by Visual C++ when I made a new project, only the D3D stuff was added, and I modified the message loop to use PeekMessage rather than GetMessage.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


Heya,

Ok I am not sure if you actually create a window, but why are you passing zero for width and height of the window in CreateWindow()?

Also how about giving d3d some info as to what the back buffer width/height should be ( or maybe it gets this automatically from the window ).

What graphics card are you programming with if I may ask?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Dont forget to call ID3D9Device::Present() after ID3D9Device::EndScene() in your Render() function or you'll have fun figuring out why your'e not getting anything displayed. :)

Share this post


Link to post
Share on other sites


Your'e cleaning up all wrong.

You release the device BEFORE direct3d itself.

Try this:



// Macro to easily release interfaces
#define SAFE_RELEASE(p) if(p) { p->Release(); p = 0; }

// Release device and direct3d
SAFE_RELEASE( Device );
SAFE_RELEASE( D3D );




- Shock

Share this post


Link to post
Share on other sites
Also, double check those resource IDs. I suspect if you debug the window class registration and window creation, one of them is failing.


LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_D3D_TEST, szWindowClass, MAX_LOADSTRING);

...

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

...

wcex.lpszMenuName = MAKEINTRESOURCE(IDC_D3D_TEST);



So what exactly is IDC_D3D_TEST?...

Is it a string resource containing the class name of your window class?

Is it a keyboard accelerator resource?

Is it a menu resource with the main menu for your application?


A problem with your resource IDs could cause a problem with your window creation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement