Skip to content

Commit

Permalink
we have the gamepad rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Sep 29, 2024
1 parent fc07b10 commit 902f6e2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
6 changes: 3 additions & 3 deletions platform/cafe/include/driver/display/Framebuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ namespace love

private:
static constexpr auto FORMAT = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
static constexpr auto BUFFER_MODE = GX2_BUFFERING_MODE_DOUBLE;
static constexpr auto BUFFER_MODE = GX2_BUFFERING_MODE_SINGLE;
static constexpr auto INVALIDATE_COLOR_BUFFER =
GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_COLOR_BUFFER;

GX2ColorBuffer target;
GX2DepthBuffer depth;

uint8_t mode;
uint8_t id;
uint8_t renderMode;
GX2ScanTarget id;

Uniform* uniform;

Expand Down
14 changes: 14 additions & 0 deletions platform/cafe/include/driver/display/Uniform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,19 @@ namespace love
{
glm::mat4 modelView;
glm::mat4 projection;

void debug()
{
const auto count = sizeof(glm::mat4) / sizeof(uint32_t);

uint32_t* model = (uint32_t*)glm::value_ptr(this->modelView);
for (size_t index = 0; index < count; index++)
std::printf("modelView[%zu] = %u\n", index, model[index]);

uint32_t* projection = (uint32_t*)glm::value_ptr(this->projection);
for (size_t index = 0; index < count; index++)
std::printf("projection[%zu] = %u\n", index, projection[index]);
}
};

} // namespace love
10 changes: 5 additions & 5 deletions platform/cafe/source/driver/display/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ namespace love

if (this->id == GX2_SCAN_TARGET_TV)
{
const auto mode = (GX2TVRenderMode)this->mode;
const auto mode = (GX2TVRenderMode)this->renderMode;
GX2SetTVBuffer(this->scanBuffer, this->scanBufferSize, mode, FORMAT, BUFFER_MODE);
}
else
{
const auto mode = (GX2DrcRenderMode)this->mode;
const auto mode = (GX2DrcRenderMode)this->renderMode;
GX2SetDRCBuffer(this->scanBuffer, this->scanBufferSize, mode, FORMAT, BUFFER_MODE);
}

Expand Down Expand Up @@ -98,7 +98,7 @@ namespace love

GX2CalcTVSize(mode, FORMAT, BUFFER_MODE, &this->scanBufferSize, &unknown);
GX2SetTVScale(info.width, info.height);
this->mode = mode;
this->renderMode = mode;
}
else
{
Expand All @@ -107,10 +107,10 @@ namespace love

GX2CalcDRCSize(mode, FORMAT, BUFFER_MODE, &this->scanBufferSize, &unknown);
GX2SetDRCScale(info.width, info.height);
this->mode = mode;
this->renderMode = mode;
}

this->id = info.id;
this->id = (GX2ScanTarget)info.id;
this->width = info.width;
this->height = info.height;

Expand Down
7 changes: 3 additions & 4 deletions platform/cafe/source/driver/display/GX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace love
{
if (!this->inFrame)
{
// GX2SetContextState(this->state);
GX2SetContextState(this->state);
this->inFrame = true;
}
}
Expand Down Expand Up @@ -223,7 +223,6 @@ namespace love

if (bindingModified)
{
// this->targets[love::currentScreen].useState();
GX2SetColorBuffer(target, GX2_RENDER_TARGET_0);
this->setMode(target->surface.width, target->surface.height);
}
Expand Down Expand Up @@ -318,8 +317,8 @@ namespace love
this->inFrame = false;
}

if (Keyboard()->hasTextInput())
nn::swkbd::DrawDRC();
// if (Keyboard()->hasTextInput())
// nn::swkbd::DrawDRC();

for (auto& target : this->targets)
target.copyScanBuffer();
Expand Down
20 changes: 10 additions & 10 deletions platform/cafe/source/modules/graphics/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace love

auto transform = graphics->getTransform();

GX2Invalidate(GX2_INVALIDATE_MODE_UNIFORM_BLOCK, uniform, sizeof(Uniform));
GX2Invalidate(INVALIDATE_UNIFORM_BLOCK, uniform, sizeof(Uniform));
GX2SetVertexUniformBlock(this->uniform.location, sizeof(Uniform), uniform);
}

Expand All @@ -119,18 +119,18 @@ namespace love

void Shader::attach()
{
// if (current != this)
// {
Graphics::flushBatchedDrawsGlobal();
if (current != this)
{
Graphics::flushBatchedDrawsGlobal();

GX2SetShaderMode(GX2_SHADER_MODE_UNIFORM_BLOCK);
GX2SetShaderMode(GX2_SHADER_MODE_UNIFORM_BLOCK);

GX2SetFetchShader(&this->program.fetchShader);
GX2SetVertexShader(this->program.vertexShader);
GX2SetPixelShader(this->program.pixelShader);
GX2SetFetchShader(&this->program.fetchShader);
GX2SetVertexShader(this->program.vertexShader);
GX2SetPixelShader(this->program.pixelShader);

current = this;
// }
current = this;
}
}

bool Shader::validate(const char* filepath, std::string& error)
Expand Down

0 comments on commit 902f6e2

Please sign in to comment.