-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for different pipeline + some associated api/error tweaks (#32)
* Tests for different pipeline + some associated api/error tweaks * Clean up some code * Run format_code * Update src/sgl/device/tests/test_pipeline_utils.slang * Update src/sgl/device/tests/test_pipeline_utils.slang * Remove tev show + fix vulkan test * Add alpha coverage test for Vulkan * Cleanup on pipeline tests --------- Co-authored-by: Chris Cummings <[email protected]>
- Loading branch information
1 parent
0bcb14d
commit 6fa4f1a
Showing
7 changed files
with
1,047 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#include "helpers.h" | ||
|
||
#include "sgl/core/config.h" | ||
#include "sgl/core/macros.h" | ||
|
||
#include <string> | ||
#include <format> | ||
|
||
#if SGL_HAS_D3D12 | ||
#include <dxgidebug.h> | ||
#include <dxgi1_3.h> | ||
#endif | ||
|
||
namespace sgl { | ||
|
||
|
||
// Reads last error from graphics layer. | ||
std::string get_last_gfx_layer_error() | ||
{ | ||
#if SGL_HAS_D3D12 | ||
IDXGIDebug* dxgiDebug = nullptr; | ||
DXGIGetDebugInterface1(0, IID_PPV_ARGS(&dxgiDebug)); | ||
if (!dxgiDebug) | ||
return ""; | ||
|
||
IDXGIInfoQueue* dxgiInfoQueue = nullptr; | ||
dxgiDebug->QueryInterface(IID_PPV_ARGS(&dxgiInfoQueue)); | ||
if (!dxgiInfoQueue) | ||
return ""; | ||
|
||
UINT64 messageCount = dxgiInfoQueue->GetNumStoredMessages(DXGI_DEBUG_ALL); | ||
if (messageCount == 0) | ||
return ""; | ||
|
||
SIZE_T messageLength = 0; | ||
dxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, messageCount - 1, nullptr, &messageLength); | ||
DXGI_INFO_QUEUE_MESSAGE* pMessage = (DXGI_INFO_QUEUE_MESSAGE*)malloc(messageLength); | ||
dxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, messageCount - 1, pMessage, &messageLength); | ||
auto res = std::string(pMessage->pDescription); | ||
free(pMessage); | ||
return res; | ||
#else | ||
// TODO: Get useful error information for other platforms if possible | ||
return ""; | ||
#endif | ||
} | ||
|
||
// Builds the user friendly message that is passed into a slang failure exception, | ||
// used by SLANG_CALL. | ||
std::string build_slang_failed_message(const char* call, SlangResult result) | ||
{ | ||
auto msg = std::format("Slang call {} failed with error: {}\n", call, result); | ||
if (static_cast<uint32_t>(result) >= 0x80000000U) { | ||
std::string gfx_error = get_last_gfx_layer_error(); | ||
if (!gfx_error.empty()) { | ||
msg += "\nLast graphics layer error:\n" + gfx_error; | ||
} | ||
} | ||
return msg; | ||
} | ||
|
||
} // namespace sgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.