mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-09 13:44:49 +12:00
[PICA] Start working on textures
This commit is contained in:
parent
f7824774eb
commit
dd17b2ecb8
5 changed files with 149 additions and 32 deletions
include/renderer_gl
|
@ -5,12 +5,16 @@
|
|||
#include "opengl.hpp"
|
||||
#include "surface_cache.hpp"
|
||||
|
||||
// More circular dependencies!
|
||||
class GPU;
|
||||
|
||||
struct Vertex {
|
||||
OpenGL::vec4 position;
|
||||
OpenGL::vec4 colour;
|
||||
};
|
||||
|
||||
class Renderer {
|
||||
GPU& gpu;
|
||||
OpenGL::Program triangleProgram;
|
||||
OpenGL::Program displayProgram;
|
||||
|
||||
|
@ -42,7 +46,7 @@ class Renderer {
|
|||
MAKE_LOG_FUNCTION(log, rendererLogger)
|
||||
|
||||
public:
|
||||
Renderer(const std::array<u32, regNum>& internalRegs) : regs(internalRegs) {}
|
||||
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs) : gpu(gpu), regs(internalRegs) {}
|
||||
|
||||
void reset();
|
||||
void display(); // Display the 3DS screen contents to the window
|
||||
|
|
60
include/renderer_gl/textures.hpp
Normal file
60
include/renderer_gl/textures.hpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include "boost/icl/interval.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "opengl.hpp"
|
||||
|
||||
template <typename T>
|
||||
using Interval = boost::icl::right_open_interval<T>;
|
||||
|
||||
struct Texture {
|
||||
enum class Formats : u32 {
|
||||
RGBA8 = 0,
|
||||
RGB8 = 1,
|
||||
RGBA5551 = 2,
|
||||
RGB565 = 3,
|
||||
RGBA4 = 4,
|
||||
IA8 = 5,
|
||||
RG8 = 6,
|
||||
I8 = 7,
|
||||
A8 = 8,
|
||||
IA4 = 9,
|
||||
I4 = 10,
|
||||
A4 = 11,
|
||||
ETC1 = 12,
|
||||
ETC1A4 = 13,
|
||||
|
||||
Trash1 = 14, Trash2 = 15 // TODO: What are these?
|
||||
};
|
||||
|
||||
u32 location;
|
||||
Formats format;
|
||||
OpenGL::uvec2 size;
|
||||
bool valid;
|
||||
|
||||
// Range of VRAM taken up by buffer
|
||||
Interval<u32> range;
|
||||
// OpenGL resources allocated to buffer
|
||||
OpenGL::Texture texture;
|
||||
|
||||
Texture() : valid(false) {}
|
||||
|
||||
Texture(u32 loc, Formats format, u32 x, u32 y, bool valid = true)
|
||||
: location(loc), format(format), size({x, y}), valid(valid) {
|
||||
|
||||
u64 endLoc = (u64)loc + sizeInBytes();
|
||||
// Check if start and end are valid here
|
||||
range = Interval<u32>(loc, (u32)endLoc);
|
||||
}
|
||||
|
||||
// For 2 textures to "match" we only care about their locations, formats, and dimensions to match
|
||||
// For other things, such as filtering mode, etc, we can just switch the attributes of the cached texture
|
||||
bool matches(Texture& other) {
|
||||
return location == other.location && format == other.format &&
|
||||
size.x() == other.size.x() && size.y() == other.size.y();
|
||||
}
|
||||
|
||||
void allocate();
|
||||
void free();
|
||||
u64 sizeInBytes();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue