Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetOverlayTexture doesn't work with a ID3D11Texture2D #1883

Open
itsMaebee opened this issue Feb 5, 2025 · 0 comments
Open

SetOverlayTexture doesn't work with a ID3D11Texture2D #1883

itsMaebee opened this issue Feb 5, 2025 · 0 comments

Comments

@itsMaebee
Copy link

itsMaebee commented Feb 5, 2025

I am attempting to create a overlay using a DirectX ID3D11Texture2D and no matter what I do I am continuously getting a 24 Error: Invalid Texture. There is no documentation on the exact format I need or anything to assist so I thought to make a issue in here. I am first creating a render target and putting it onto a Texture2D. Which holds my window pixel information.

Below is the code I use to create my texture.

bool CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 2;
sd.BufferDesc.Width = WIDTH;
sd.BufferDesc.Height = HEIGHT;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

UINT createDeviceFlags = 0;
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
D3D_FEATURE_LEVEL featureLevel;
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
HRESULT res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
if (res == DXGI_ERROR_UNSUPPORTED) // Try high-performance WARP software driver if hardware is not available.
	res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_WARP, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
if (res != S_OK)
	return false;

CreateRenderTarget();
}

void CreateRenderTarget()
{
	
	g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
	g_pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &g_mainRenderTargetView);
	pBackBuffer->Release();
}




			
			
vrTex.handle = (void*)static_cast<ID3D11Texture2D*>(pBackBuffer);
			
vr::HmdVector2_t mouseScale = { (float)WIDTH, (float)HEIGHT };
VRTextureBounds_t bounds;
bounds.uMin = 0;
bounds.vMin = 0;
bounds.uMax = 1;
bounds.vMax = 1;
VROverlay()->SetOverlayTextureBounds(dashboardOverlayHandle, &bounds);
erroro2 = vr::VROverlay()->SetOverlayTexture(dashboardOverlayHandle, &vrTex);
if (erroro2 != vr::VROverlayError_None) {
	logger.log("Failed to Set Overlay Texture: %s\n", erroro2);
	return false;
}
			


If I use DirectX to get the pixels and set it using SetOverlayRaw it works fine but that isn't a suitable fix. Is there anything I could be missing? I am using ImGui for the overlay. I'm on Windows 10 with a NVIDIA graphics card and a AMD Ryzen 7 Card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant