beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks

Post on 13-Feb-2017

42 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Beginning Direct3D Game Programming:2. Overview of HAL and

COMjintaeks@gmail.com

Division of Digital Contents, DongSeo University.April 2016

HAL: Hardware Abstraction Layer

In DirectX 8.0/9.0 games, you might choose between a HAL, a pluggable software device, or a reference raster-izer; or the application might select one automatically.

You will find this device selection box, called the Direc-t3D Settings dialog box, in every Direct3D example pro-gram delivered with the DirectX 9.0 SDK.

2

3

The relationships among the Direct3D API, HAL, and GDI(Graphics Device Interface) APIs.

HAL is the primary device type, and it supports hard-ware-accelerated rasterization and both hardware and software vertex processing.

4

Device Name Use DxDiag to check device name.

5

HAL is also able to emulate vertex processing in soft-ware completely or in parts.

The following flags control vertex-processing behavior for HAL and reference devices:– D3DCREATE_SOFTWARE_VERTEXPROCESSING– D3DCREATE_HARDWARE_VERTEXPROCESSING– D3DCREATE_MIXED_VERTEXPROCESSING

Pure Device– HAL is able to switch on a so-called pure device.– This device uses a reduced number of state checks and is avail-

able only if specific functions of the Direct3D API are not used.– It is a bit faster than the non-pure hardware vertex-processing

device.

6

Reference Rasterizer The reference device is supplied only with the installa-

tion of the SDK. The reference rasterizer supports all Direct3D features.

You should only use it to test features that your card doesn’t support.

This device is optimized for accuracy, not for speed.

7

Controlling Devices You can configure all con-

trolling devices in the Di-rectX Properties dialog box.

8

GPU-Z Use GPU-Z tool to measure

GPU memory.

9

Fraps Draw FPS on any DirectX surfaces of running process. Benchmark FPS of DirectX program.

10

Example: BasicHLSL Build and run BasicHLSL project in Sdk. Change device to reference rasterizer and check FPS us-

ing Fraps.

11

COM: Component Object Model Component Object Model (COM) is a binary-interface

 standard for software components introduced by Microsoftin 1993.

It is used to enable inter-process communication and dynamic object creation in a large range of programming languages.

The essence of COM is a language-neutral way of im-plementing objects that can be used in environments different from the one in which they were created.

12

COM in DirectX COM provides a versioning strategy, which guarantees

that all games developed in earlier versions of DirectX are guaranteed to run in future versions.

It helps you encapsulate data and provides a consistent interface to different languages.

13

Using COM for IPC Applications that use OLE manage compound docu-

ments—that is, documents made up of data from a vari-ety of different applications.

OLE provides services that make it easy for applications to call on other applications for data editing.

For example, a word processor that uses OLE could em-bed a graph from a spreadsheet. The user could start the spreadsheet automatically from within the word pro-cessor by choosing the embedded chart for editing. 

14

Technical details COM programmers build their software using COM-

aware components. Different component types are identified by class IDs

(CLSIDs), which are Globally Unique Identifiers (GUIDs). Each COM component exposes its functionality through

one or more interfaces. The different interfaces supported by a component are

distinguished from each other using interface IDs (IIDs), which are GUIDs too.

15

IUnknown All COM components implement the IUnknown (custom)

interface, which exposes methods for reference counting and type conversion (casting).

A custom IUnknown interface consists of a pointer to a virtual method table that contains a list of pointers to the functions that implement the functions declared in the interface.

16

Classes A COM class (coclass) is a concrete implementation of

one or more interfaces, and closely resembles classes in object-oriented programming languages. Classes are created based on their class ID (CLSID) or based on their programmatic identifier string (progid).

Like many object-oriented languages, COM provides a separation of interface from implementation.

17

Practiceclass IUnknown {public: virtual void CreateInstance() = 0;};

class KFirst : public IUnknown { virtual void CreateInstance() { printf( "Hello First\r\n" ); }};

class KSecond : public IUnknown { virtual void CreateInstance() { printf( "Hello Second\r\n" ); }};

18

void main() { IUnknown* pUnknown = nullptr; KFirst first; KSecond second; pUnknown = &first; pUnknown->CreateInstance(); pUnknown = &second; pUnknown->CreateInstance();}

19

top related