1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +01:00

[util] Move DecodeD3DColor to util

This will be used in the D3D11UserDefinedAnnotation implementation to handle PIX calls which contain a color.
This commit is contained in:
Joshua Ashton 2021-04-30 09:03:51 +01:00 committed by Philip Rebohle
parent d5d5c1a8bc
commit a010397f34
2 changed files with 16 additions and 8 deletions

View File

@ -9,6 +9,7 @@
#include "../dxvk/dxvk_device.h" #include "../dxvk/dxvk_device.h"
#include "../util/util_matrix.h" #include "../util/util_matrix.h"
#include "../util/util_misc.h"
#include <d3dcommon.h> #include <d3dcommon.h>
@ -102,14 +103,6 @@ namespace dxvk {
VkImageUsageFlags GetImageUsageFlags(DWORD Usage); VkImageUsageFlags GetImageUsageFlags(DWORD Usage);
inline void DecodeD3DCOLOR(D3DCOLOR color, float* rgba) {
// Encoded in D3DCOLOR as argb
rgba[3] = (float)((color & 0xff000000) >> 24) / 255.0f;
rgba[0] = (float)((color & 0x00ff0000) >> 16) / 255.0f;
rgba[1] = (float)((color & 0x0000ff00) >> 8) / 255.0f;
rgba[2] = (float)((color & 0x000000ff)) / 255.0f;
}
inline VkFormat PickSRGB(VkFormat format, VkFormat srgbFormat, bool srgb) { inline VkFormat PickSRGB(VkFormat format, VkFormat srgbFormat, bool srgb) {
return srgb ? srgbFormat : format; return srgb ? srgbFormat : format;
} }

15
src/util/util_misc.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include <d3d9types.h>
namespace dxvk {
inline void DecodeD3DCOLOR(D3DCOLOR color, float* rgba) {
// Encoded in D3DCOLOR as argb
rgba[3] = (float)((color & 0xff000000) >> 24) / 255.0f;
rgba[0] = (float)((color & 0x00ff0000) >> 16) / 255.0f;
rgba[1] = (float)((color & 0x0000ff00) >> 8) / 255.0f;
rgba[2] = (float)((color & 0x000000ff)) / 255.0f;
}
}