Forum

Notifications
Clear all

DirextX 12 3D Video Game Engine with AMD ROCm

1 Posts
1 Users
0 Reactions
16 Views
 josh
(@josh)
Member Admin
Joined: 2 months ago
Posts: 510
Topic starter  

Let’s architect a modular 3D game engine that showcases the top 20 DirectX 12 and AMD ROCm API calls, with clean separation between rendering, compute, and engine logic. This will give you a high-performance, extensible foundation for integrating neural workflows, asset pipelines, and cognition routing later.


🗂 Folder Structure

NeuroEngine/
├── Assets/                  # Placeholder for textures, models, shaders
├── Engine/
│   ├── Core/                # Initialization, windowing, input
│   ├── Graphics/            # DirectX 12 rendering pipeline
│   ├── Compute/             # ROCm HIP compute modules
│   └── Utils/               # Logging, profiling, memory
├── Shaders/
│   ├── HLSL/                # DX12 shaders
│   └── HIP/                 # ROCm kernels
├── ThirdParty/              # DX12/ROCm headers, helper libs
├── App/
│   └── Main.cpp             # Entry point
├── CMakeLists.txt           # Build configuration
└── README.md

🔧 Top DirectX 12 API Calls Used

Category API Calls
Device & Adapter D3D12CreateDevice, IDXGIFactory4::EnumAdapters1, IDXGIAdapter1::GetDesc1
Command Queue CreateCommandQueue, ExecuteCommandLists
Swap Chain CreateSwapChain, Present
Descriptor Heaps CreateDescriptorHeap, CreateRenderTargetView, CreateDepthStencilView
Resource Mgmt CreateCommittedResource, Map, Unmap, CopyResource
Pipeline State CreateGraphicsPipelineState, CreateRootSignature, SetGraphicsRootSignature
Command Lists CreateCommandList, Close, Reset, DrawInstanced
Synchronization CreateFence, Signal, WaitForSingleObject

⚙️ Top AMD ROCm HIP API Calls Used

Category API Calls
Initialization hipInit, hipGetDeviceProperties, hipSetDevice
Memory Mgmt hipMalloc, hipMemcpy, hipFree, hipMemset
Kernel Launch hipLaunchKernelGGL, hipConfigureCall, hipModuleLaunchKernel
Streams & Events hipStreamCreate, hipStreamSynchronize, hipEventRecord, hipEventSynchronize
Error Handling hipGetLastError, hipPeekAtLastError, hipGetErrorString

🧠 Sample Code Snippets

📁 Engine/Core/Init.cpp

// DXGI Factory and Device
ComPtr<IDXGIFactory4> dxgiFactory;
CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory));

ComPtr<IDXGIAdapter1> adapter;
dxgiFactory->EnumAdapters1(0, &adapter);

ComPtr<ID3D12Device> device;
D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_12_1, IID_PPV_ARGS(&device));

📁 Engine/Graphics/Renderer.cpp

// Command Queue
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&commandQueue));

// Swap Chain
DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
dxgiFactory->CreateSwapChain(commandQueue.Get(), &swapChainDesc, &swapChain);

// Render Target View
device->CreateRenderTargetView(renderTarget.Get(), nullptr, rtvHeap->GetCPUDescriptorHandleForHeapStart());

📁 Engine/Compute/HIPInterop.cpp

#include <hip/hip_runtime.h>

__global__ void ComputeLighting(float3* positions, float3* normals, float3* output) {
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    output[idx] = positions[idx] + normals[idx]; // Simplified lighting
}

extern "C" void LaunchLightingKernel(float3* d_positions, float3* d_normals, float3* d_output, int count) {
    int threads = 256;
    int blocks = (count + threads - 1) / threads;
    hipLaunchKernelGGL(ComputeLighting, dim3(blocks), dim3(threads), 0, 0, d_positions, d_normals, d_output);
    hipDeviceSynchronize();
}

📁 App/Main.cpp

#include "Engine/Core/Init.h"
#include "Engine/Graphics/Renderer.h"
#include "Engine/Compute/HIPInterop.h"

int main() {
    InitEngine();         // DX12 + Window
    InitHIP();            // ROCm device setup
    while (IsRunning()) {
        UpdateScene();    // Game logic
        RunCompute();     // HIP lighting
        RenderFrame();    // DX12 draw call
    }
    Shutdown();
    return 0;
}

🧱 Modular Extensibility

  • Assets: Plug in FBX/GLTF models, DDS textures, and HLSL shaders.
  • Compute: Expand HIP kernels for physics, AI, or cognition workflows.
  • Graphics: Add shadow mapping, deferred rendering, or ray tracing.
  • Engine: Integrate ECS, input systems, and audio pipelines.

 


   
Quote
Share: