File: VertexLoaderUtils.h

package info (click to toggle)
dolphin-emu 2512%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 76,328 kB
  • sloc: cpp: 499,023; ansic: 119,674; python: 6,547; sh: 2,338; makefile: 1,093; asm: 726; pascal: 257; javascript: 183; perl: 97; objc: 75; xml: 30
file content (61 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <cstring>

#include "Common/CommonTypes.h"
#include "Common/Inline.h"
#include "Common/Swap.h"

extern const u8* g_video_buffer_read_ptr;
extern u8* g_vertex_manager_write_ptr;

DOLPHIN_FORCE_INLINE void DataSkip(u32 skip)
{
  g_video_buffer_read_ptr += skip;
}

// probably unnecessary
template <int count>
DOLPHIN_FORCE_INLINE void DataSkip()
{
  g_video_buffer_read_ptr += count;
}

template <typename T>
DOLPHIN_FORCE_INLINE T DataPeek(int _uOffset, const u8* bufp = g_video_buffer_read_ptr)
{
  T result;
  std::memcpy(&result, &bufp[_uOffset], sizeof(T));
  return Common::FromBigEndian(result);
}

template <typename T>
DOLPHIN_FORCE_INLINE T DataRead(const u8** bufp = &g_video_buffer_read_ptr)
{
  auto const result = DataPeek<T>(0, *bufp);
  *bufp += sizeof(T);
  return result;
}

DOLPHIN_FORCE_INLINE u32 DataReadU32Unswapped()
{
  u32 result;
  std::memcpy(&result, g_video_buffer_read_ptr, sizeof(u32));
  g_video_buffer_read_ptr += sizeof(u32);
  return result;
}

DOLPHIN_FORCE_INLINE const u8* DataGetPosition()
{
  return g_video_buffer_read_ptr;
}

template <typename T>
DOLPHIN_FORCE_INLINE void DataWrite(T data)
{
  std::memcpy(g_vertex_manager_write_ptr, &data, sizeof(T));
  g_vertex_manager_write_ptr += sizeof(T);
}