Refactor FourCC magic uses

- Use new fourcc_t type
- Improves compiler compatibility by removing multi chars
This commit is contained in:
Joel Linn
2021-05-06 18:46:43 +02:00
committed by Rick Gibbed
parent 4daa3f5a52
commit a86d7173e1
25 changed files with 65 additions and 42 deletions

View File

@@ -824,8 +824,8 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(RingBuffer* reader,
// VdSwap will post this to tell us we need to swap the screen/fire an
// interrupt.
// 63 words here, but only the first has any data.
uint32_t magic = reader->ReadAndSwap<uint32_t>();
assert_true(magic == 'SWAP');
uint32_t magic = reader->ReadAndSwap<fourcc_t>();
assert_true(magic == kSwapSignature);
// TODO(benvanik): only swap frontbuffer ptr.
uint32_t frontbuffer_ptr = reader->ReadAndSwap<uint32_t>();

View File

@@ -30,7 +30,7 @@ void TextureDump(const TextureInfo& src, void* buffer, size_t length) {
struct {
uint32_t size;
uint32_t flags;
uint32_t fourcc;
be<fourcc_t> fourcc;
uint32_t rgb_bit_count;
uint32_t r_bit_mask;
uint32_t g_bit_mask;
@@ -59,17 +59,17 @@ void TextureDump(const TextureInfo& src, void* buffer, size_t length) {
switch (src.format) {
case xenos::TextureFormat::k_DXT1: {
dds_header.pixel_format.flags = 0x4u;
dds_header.pixel_format.fourcc = '1TXD';
dds_header.pixel_format.fourcc = make_fourcc("DXT1");
break;
}
case xenos::TextureFormat::k_DXT2_3: {
dds_header.pixel_format.flags = 0x4u;
dds_header.pixel_format.fourcc = '3TXD';
dds_header.pixel_format.fourcc = make_fourcc("DXT3");
break;
}
case xenos::TextureFormat::k_DXT4_5: {
dds_header.pixel_format.flags = 0x4u;
dds_header.pixel_format.fourcc = '5TXD';
dds_header.pixel_format.fourcc = make_fourcc("DXT5");
break;
}
case xenos::TextureFormat::k_8_8_8_8: {
@@ -100,7 +100,7 @@ void TextureDump(const TextureInfo& src, void* buffer, size_t length) {
FILE* handle = filesystem::OpenFile(path, "wb");
if (handle) {
const uint32_t signature = ' SDD';
const char signature[4] = {'D', 'D', 'S', ' '};
fwrite(&signature, sizeof(signature), 1, handle);
fwrite(&dds_header, sizeof(dds_header), 1, handle);
fwrite(buffer, 1, length, handle);

View File

@@ -15,6 +15,7 @@
#include "xenia/base/assert.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/math.h"
#include "xenia/base/memory.h"
#include "xenia/base/platform.h"
namespace xe {
@@ -27,6 +28,8 @@ namespace xenos {
// in bit fields (registers are 32-bit, and the microcode consists of triples of
// 32-bit words).
constexpr fourcc_t kSwapSignature = make_fourcc("SWAP");
enum class ShaderType : uint32_t {
kVertex = 0,
kPixel = 1,