Skip to content

Commit 3eaaaa3

Browse files
committed
feat(igpu-shaders): prepare blind-review diffs for shader/iGPU integration
This change introduces pre-activation scaffolds for iGPU/shader integration to enable blind review before activation. It adds iGPU detection hooks and related state, shader support placeholders, and a ShaderRendererEnabled flag. All new iGPU/shader code is prefixed with // #--- to allow mass-activation later.
1 parent 4901538 commit 3eaaaa3

4 files changed

Lines changed: 326 additions & 0 deletions

File tree

AdapterOption.h.blind.diff

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
diff --git a/Common/Include/AdapterOption.h b/Common/Include/AdapterOption.h
2+
index 9c2e8e1..b8b3b23 100644
3+
--- a/Common/Include/AdapterOption.h
4+
+++ b/Common/Include/AdapterOption.h
5+
@@ -65,6 +65,100 @@ vector<GPUInfo> getAvailableGPUs() {
6+
7+
return gpus;
8+
}
9+
+
10+
+// #--- // Find the integrated GPU (iGPU) from available adapters
11+
+// #--- // Returns optional LUID if iGPU is found, nullopt otherwise
12+
+// #--- inline std::optional<LUID> findiGPU() {
13+
+// #--- auto gpus = getAvailableGPUs();
14+
+// #--- if (gpus.empty()) {
15+
+// #--- return std::nullopt;
16+
+// #--- }
17+
+// #---
18+
+// #--- // iGPU detection criteria:
19+
+// #--- // 1. Not a software adapter (has dedicated video memory > 0)
20+
+// #--- // 2. Low dedicated video memory (typically < 512MB for integrated)
21+
+// #--- // 3. Usually Intel HD/UHD graphics (Vendor ID 0x8086) or AMD APU (Vendor ID 0x1002)
22+
+// #--- // 4. Often the GPU with least dedicated memory (excluding software adapters)
23+
+// #---
24+
+// #--- const UINT64 iGPUMemoryThreshold = 512ULL * 1024ULL * 1024ULL; // 512MB threshold
25+
+// #--- const UINT intelVendorId = 0x8086; // Intel
26+
+// #--- const UINT amdVendorId = 0x1002; // AMD (for APUs)
27+
+// #---
28+
+// #--- std::optional<LUID> iGPULuid = std::nullopt;
29+
+// #--- UINT64 minDedicatedMemory = UINT64_MAX;
30+
+// #--- const GPUInfo* candidateGPU = nullptr;
31+
+// #---
32+
+// #--- // First pass: Look for Intel or AMD integrated graphics with low memory
33+
+// #--- for (const auto& gpu : gpus) {
34+
+// #--- const auto& desc = gpu.desc;
35+
+// #---
36+
+// #--- // Skip software adapters (zero dedicated memory)
37+
+// #--- if (desc.DedicatedVideoMemory == 0) {
38+
+// #--- continue;
39+
+// #--- }
40+
+// #---
41+
+// #--- // Check for integrated GPU characteristics
42+
+// #--- bool isLikelyiGPU = false;
43+
+// #---
44+
+// #--- // Check by vendor ID (Intel or AMD APU)
45+
+// #--- if (desc.VendorId == intelVendorId || desc.VendorId == amdVendorId) {
46+
+// #--- // Intel HD/UHD graphics typically have specific naming patterns
47+
+// #--- wstring name = desc.Description;
48+
+// #--- if (name.find(L"Intel") != wstring::npos &&
49+
+// #--- (name.find(L"HD") != wstring::npos || name.find(L"UHD") != wstring::npos)) {
50+
+// #--- isLikelyiGPU = true;
51+
+// #--- }
52+
+// #--- // Check if it has low dedicated memory (typical for iGPU)
53+
+// #--- if (desc.DedicatedVideoMemory < iGPUMemoryThreshold) {
54+
+// #--- isLikelyiGPU = true;
55+
+// #--- }
56+
+// #--- }
57+
+// #---
58+
+// #--- // Track the GPU with least dedicated memory (usually iGPU)
59+
+// #--- if (desc.DedicatedVideoMemory < minDedicatedMemory) {
60+
+// #--- minDedicatedMemory = desc.DedicatedVideoMemory;
61+
+// #--- // Prioritize Intel/AMD candidates, but also consider low memory GPUs
62+
+// #--- if (isLikelyiGPU || desc.DedicatedVideoMemory < iGPUMemoryThreshold) {
63+
+// #--- candidateGPU = &gpu;
64+
+// #--- }
65+
+// #--- }
66+
+// #--- }
67+
+// #---
68+
+// #--- // If we found a candidate with Intel/AMD or low memory, return it
69+
+// #--- if (candidateGPU != nullptr) {
70+
+// #--- return candidateGPU->desc.AdapterLuid;
71+
+// #--- }
72+
+// #---
73+
+// #--- // Fallback: If no clear iGPU found by vendor, return the GPU with least memory
74+
+// #--- // (assuming discrete GPUs typically have more memory)
75+
+// #--- if (minDedicatedMemory != UINT64_MAX && minDedicatedMemory < iGPUMemoryThreshold) {
76+
+// #--- for (const auto& gpu : gpus) {
77+
+// #--- if (gpu.desc.DedicatedVideoMemory == minDedicatedMemory) {
78+
+// #--- return gpu.desc.AdapterLuid;
79+
+// #--- }
80+
+// #--- }
81+
+// #--- }
82+
+// #---
83+
+// #--- return std::nullopt;
84+
+// #--- }
85+
+
86+
+// #--- // Get iGPU name if available
87+
+// #--- inline wstring getiGPUName() {
88+
+// #--- auto luidOpt = findiGPU();
89+
+// #--- if (!luidOpt.has_value()) {
90+
+// #--- return L"";
91+
+// #--- }
92+
+// #---
93+
+// #--- auto gpus = getAvailableGPUs();
94+
+// #--- for (const auto& gpu : gpus) {
95+
+// #--- if (gpu.desc.AdapterLuid.LowPart == luidOpt.value().LowPart &&
96+
+// #--- gpu.desc.AdapterLuid.HighPart == luidOpt.value().HighPart) {
97+
+// #--- return gpu.name;
98+
+// #--- }
99+
+// #--- }
100+
+// #---
101+
+// #--- return L"";
102+
+// #--- }
103+
@@ -132,6 +226,11 @@ public:
104+
bool hasTargetAdapter{}; // Indicates if a target adapter is selected
105+
LUID adapterLuid{}; // Adapter's unique identifier (LUID)
106+
wstring target_name{}; // Target adapter name
107+
+
108+
+// #--- // --- iGPU SUPPORT ---
109+
+// #--- bool hasiGPU{}; // Indicates if an iGPU was detected
110+
+// #--- LUID iGPULuid{}; // Integrated GPU's unique identifier (LUID)
111+
+// #--- wstring iGPU_name{}; // Integrated GPU name
112+
+// #--- // --- END iGPU SUPPORT ---
113+
@@ -188,6 +287,39 @@ public:
114+
IddCxAdapterSetRenderAdapter(adapter, &arg);
115+
}
116+
}
117+
+
118+
+// #--- // --- iGPU DETECTION METHODS ---
119+
+// #--- // Detect and select the integrated GPU (iGPU)
120+
+// #--- // Returns true if iGPU is found and set, false otherwise
121+
+// #--- bool selectiGPU() {
122+
+// #--- auto luidOpt = findiGPU();
123+
+// #--- if (luidOpt.has_value()) {
124+
+// #--- iGPULuid = luidOpt.value();
125+
+// #--- iGPU_name = getiGPUName();
126+
+// #--- hasiGPU = true;
127+
+// #--- return true;
128+
+// #--- }
129+
+// #--- hasiGPU = false;
130+
+// #--- return false;
131+
+// #--- }
132+
+// #---
133+
+// #--- // Get the iGPU LUID if available
134+
+// #--- std::optional<LUID> getiGPULuid() const {
135+
+// #--- if (hasiGPU) {
136+
+// #--- return iGPULuid;
137+
+// #--- }
138+
+// #--- return std::nullopt;
139+
+// #--- }
140+
+// #---
141+
+// #--- // Check if iGPU is available
142+
+// #--- bool hasIntegratedGPU() const {
143+
+// #--- return hasiGPU;
144+
+// #--- }
145+
+// #---
146+
+// #--- // Get iGPU name
147+
+// #--- wstring getiGPUName() const {
148+
+// #--- return iGPU_name;
149+
+// #--- }
150+
+// #--- // --- END iGPU DETECTION METHODS ---
151+
152+
private:
153+
// Find and set the adapter by name, optionally using "name,bus" where bus is the PCI bus number.

BLIND_REVIEW_DIFFS_README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Blind Review Diffs - Shader/iGPU Integration
2+
3+
## Overview
4+
Three unified diff files have been generated to show the integration of shader and iGPU-related code into the Virtual Display Driver. All shader/iGPU code is prefixed with `// #--- ` for blind review purposes.
5+
6+
## Critical Formatting Rules Applied
7+
8+
1. **Code lines**: `// #--- [code]` (e.g., `// #--- int x = 0;`)
9+
2. **Remarks/comments**: `// #--- // [text]` (e.g., `// #--- // iGPU detection function`)
10+
3. **Later activation**: Remove `// #--- ` globally to activate all code while preserving comments
11+
12+
## Generated Diff Files
13+
14+
### 1. AdapterOption.h.blind.diff
15+
**Location**: `/Common/Include/AdapterOption.h`
16+
17+
**Added iGPU functionality** (all prefixed with `// #--- `):
18+
- `findiGPU()` - Standalone function to find integrated GPU (lines 68-142 in testcode)
19+
- Detects iGPU by vendor ID (Intel 0x8086, AMD 0x1002)
20+
- Memory threshold-based detection (< 512MB)
21+
- Intel HD/UHD graphics name pattern matching
22+
- `getiGPUName()` - Standalone function to get iGPU name (lines 144-160 in testcode)
23+
- **Class member variables**:
24+
- `bool hasiGPU` - Indicates if iGPU was detected
25+
- `LUID iGPULuid` - Integrated GPU's unique identifier
26+
- `wstring iGPU_name` - Integrated GPU name
27+
- **Class methods**:
28+
- `selectiGPU()` - Detect and select the iGPU, returns true if found
29+
- `getiGPULuid()` - Get the iGPU LUID if available
30+
- `hasIntegratedGPU()` - Check if iGPU is available
31+
- `getiGPUName()` - Get iGPU name
32+
33+
**Note**: `ResolveAdapterLuidFromPciBus()` was NOT included as it already exists in the destination file (lines 70-128).
34+
35+
### 2. Driver.h.blind.diff
36+
**Location**: `/Virtual Display Driver (HDR)/MttVDD/Driver.h`
37+
38+
**Added shader support members** in `Direct3DDevice` struct (all prefixed with `// #--- `):
39+
- `Microsoft::WRL::ComPtr<ID3D11VertexShader> VertexShader` - Vertex shader for frame processing
40+
- `Microsoft::WRL::ComPtr<ID3D11PixelShader> PixelShader` - Pixel shader for frame processing
41+
- `Microsoft::WRL::ComPtr<ID3D11Buffer> PerFrameBuffer` - Optional constant buffers for shader parameters
42+
- All shader members are commented out (double-commented) to show they're optional/planned additions
43+
44+
### 3. Driver.cpp.blind.diff
45+
**Location**: `/Virtual Display Driver (HDR)/MttVDD/Driver.cpp`
46+
47+
**Added shader/iGPU global variables** (all prefixed with `// #--- `):
48+
- `std::vector<BYTE> g_VertexShaderBytecode` - Global vertex shader bytecode storage
49+
- `std::vector<BYTE> g_PixelShaderBytecode` - Global pixel shader bytecode storage
50+
- `wstring g_ShaderHeaderPath` - Path to shader header files
51+
- `bool g_ShaderEnabled` - Flag to enable/disable shader rendering
52+
53+
**Added multi-GPU shader variables** (all commented out and prefixed with `// #--- `):
54+
- `bool g_UseiGPUForShaders` - Enable iGPU for shader processing while displaying on dGPU
55+
- `LUID g_iGPULuid` - iGPU LUID for shader processing (commented out)
56+
- `std::shared_ptr<Direct3DDevice> g_iGPUDevice` - iGPU Direct3DDevice for shaders (commented out)
57+
- `Microsoft::WRL::ComPtr<ID3D11Texture2D> g_StagingTexture` - Cross-adapter staging texture (commented out)
58+
- `Microsoft::WRL::ComPtr<ID3D11RenderTargetView> g_iGPURenderTarget` - iGPU render target (commented out)
59+
60+
**Added SettingsQueryMap entry**:
61+
- `{L"ShaderRendererEnabled", {L"SHADERRENDERER", L"shader_renderer"}}` - Settings query for shader renderer
62+
63+
## Integration Workflow
64+
65+
### Current State (Blind Review)
66+
All shader/iGPU code is disabled and marked with `// #--- ` prefix:
67+
```cpp
68+
// #--- bool g_ShaderEnabled = false;
69+
// #--- // iGPU detection function
70+
```
71+
72+
### Activation Workflow
73+
1. **Manual Review**: Review all diffs to identify conflicts with existing code
74+
2. **Resolve Conflicts**: Manually merge any overlapping functionality
75+
3. **Global Activation**: Use find-and-replace to remove `// #--- ` prefix:
76+
- Find: `// #--- `
77+
- Replace: (empty)
78+
4. **Result**: All code activates while preserving comments:
79+
```cpp
80+
bool g_ShaderEnabled = false;
81+
// iGPU detection function
82+
```
83+
84+
## Key Observations
85+
86+
### AdapterOption.h
87+
- The testcode version includes comprehensive iGPU detection logic not present in the current version
88+
- No conflicts with `ResolveAdapterLuidFromPciBus()` as it already exists in the current file
89+
- Class members can be safely added without breaking existing functionality
90+
91+
### Driver.h
92+
- Shader support members are additive - no existing code conflicts
93+
- All shader members are commented out, showing they're planned additions
94+
- Integration requires uncommenting during activation
95+
96+
### Driver.cpp
97+
- Shader variables are new additions after line 116 (`wstring ColourFormat`)
98+
- Multi-GPU shader variables are mostly commented out (double-commented)
99+
- SettingsQueryMap entry fits between "Colour End" and "EDID Integration Begin" sections
100+
- No conflicts with existing variables
101+
102+
## Next Steps
103+
104+
1. **Apply diffs manually** to review integration points
105+
2. **Test for conflicts** with existing code patterns
106+
3. **Verify compatibility** with current driver architecture
107+
4. **Global find-replace** to activate: Remove `// #--- ` prefix
108+
5. **Compile and test** to ensure shader/iGPU functionality works correctly
109+
110+
## File Locations
111+
- `AdapterOption.h.blind.diff` - iGPU detection and selection functionality
112+
- `Driver.h.blind.diff` - Shader support members for Direct3DDevice
113+
- `Driver.cpp.blind.diff` - Global shader/iGPU variables and settings
114+
115+
All diffs use unified format with context lines for clear integration mapping.

Driver.cpp.blind.diff

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/Virtual Display Driver (HDR)/MttVDD/Driver.cpp b/Virtual Display Driver (HDR)/MttVDD/Driver.cpp
2+
index 7d3b2c1..b2d9a6f 100644
3+
--- a/Virtual Display Driver (HDR)/MttVDD/Driver.cpp
4+
+++ b/Virtual Display Driver (HDR)/MttVDD/Driver.cpp
5+
@@ -113,6 +113,24 @@ IDDCX_BITS_PER_COMPONENT HDRCOLOUR = IDDCX_BITS_PER_COMPONENT_10;
6+
7+
wstring ColourFormat = L"RGB";
8+
+
9+
+// #--- // --- SHADER SUPPORT VARIABLES ---
10+
+// #--- // Global shader bytecode storage
11+
+// #--- std::vector<BYTE> g_VertexShaderBytecode;
12+
+// #--- std::vector<BYTE> g_PixelShaderBytecode;
13+
+// #--- wstring g_ShaderHeaderPath = L"";
14+
+// #--- bool g_ShaderEnabled = false;
15+
+// #---
16+
+// #--- // --- MULTI-GPU SHADER RENDERING VARIABLES ---
17+
+// #--- // Enable iGPU for shader processing while displaying on selected dGPU
18+
+// #--- bool g_UseiGPUForShaders = false; // Configurable via pipe/XML
19+
+// #--- // LUID g_iGPULuid = {}; // iGPU LUID for shader processing
20+
+// #--- // std::shared_ptr<Direct3DDevice> g_iGPUDevice = nullptr; // iGPU Direct3DDevice for shaders
21+
+// #--- // Microsoft::WRL::ComPtr<ID3D11Texture2D> g_StagingTexture = nullptr; // Cross-adapter staging texture
22+
+// #--- // Microsoft::WRL::ComPtr<ID3D11RenderTargetView> g_iGPURenderTarget = nullptr; // iGPU render target for shader output
23+
+// #--- // --- END MULTI-GPU SHADER RENDERING VARIABLES ---
24+
+// #---
25+
+// #--- // --- END SHADER SUPPORT VARIABLES ---
26+
27+
// === EDID INTEGRATION SETTINGS ===
28+
bool edidIntegrationEnabled = false;
29+
@@ -193,6 +211,10 @@ std::map<std::wstring, std::pair<std::wstring, std::wstring>> SettingsQueryMap =
30+
//Colour End
31+
32+
+ // #--- //Shaders Begin
33+
+ // #--- {L"ShaderRendererEnabled", {L"SHADERRENDERER", L"shader_renderer"}},
34+
+ // #--- //Shaders End
35+
+
36+
//EDID Integration Begin
37+
{L"EdidIntegrationEnabled", {L"EDIDINTEGRATION", L"enabled"}},
38+
{L"AutoConfigureFromEdid", {L"AUTOCONFIGFROMEDID", L"auto_configure_from_edid"}},

Driver.h.blind.diff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/Virtual Display Driver (HDR)/MttVDD/Driver.h b/Virtual Display Driver (HDR)/MttVDD/Driver.h
2+
index 5c8e9f2..3b9c4e1 100644
3+
--- a/Virtual Display Driver (HDR)/MttVDD/Driver.h
4+
+++ b/Virtual Display Driver (HDR)/MttVDD/Driver.h
5+
@@ -64,6 +64,13 @@ namespace Microsoft
6+
Microsoft::WRL::ComPtr<IDXGIAdapter1> Adapter;
7+
Microsoft::WRL::ComPtr<ID3D11Device> Device;
8+
Microsoft::WRL::ComPtr<ID3D11DeviceContext> DeviceContext;
9+
+
10+
+// #--- // --- SHADER SUPPORT MEMBERS ---
11+
+// #--- // Vertex and pixel shaders for frame processing
12+
+// #--- // These are created from loaded shader bytecode during Init()
13+
+// #--- // Microsoft::WRL::ComPtr<ID3D11VertexShader> VertexShader;
14+
+// #--- // Microsoft::WRL::ComPtr<ID3D11PixelShader> PixelShader;
15+
+// #--- // Optional: Constant buffers for shader parameters
16+
+// #--- // Microsoft::WRL::ComPtr<ID3D11Buffer> PerFrameBuffer;
17+
+// #--- // --- END SHADER SUPPORT MEMBERS ---
18+
};
19+
20+
/// <summary>

0 commit comments

Comments
 (0)