Skip to content

Commit

Permalink
Merge pull request #355 from magumagu/gx-missing-opcode
Browse files Browse the repository at this point in the history
Opcode decoding: handle missing opcodes 0x88 etc.
  • Loading branch information
neobrain committed May 18, 2014
2 parents db96f86 + 9b82d72 commit 6950f53
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
5 changes: 4 additions & 1 deletion Source/Core/VideoBackends/Software/OpcodeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ namespace OpcodeDecoder
#define GX_PRIMITIVE_SHIFT 3
#define GX_VAT_MASK 0x07

//these are defined 1/8th of their real values and without their top bit
// These values are the values extracted using GX_PRIMITIVE_MASK
// and GX_PRIMITIVE_SHIFT.
// GX_DRAW_QUADS_2 behaves the same way as GX_DRAW_QUADS.
#define GX_DRAW_QUADS 0x0 //0x80
#define GX_DRAW_QUADS_2 0x1 //0x88
#define GX_DRAW_TRIANGLES 0x2 //0x90
#define GX_DRAW_TRIANGLE_STRIP 0x3 //0x98
#define GX_DRAW_TRIANGLE_FAN 0x4 //0xA0
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/Software/SetupUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ void SetupUnit::SetupVertex()
case GX_DRAW_QUADS:
SetupQuad();
break;
case GX_DRAW_QUADS_2:
WARN_LOG(VIDEO, "Non-standard primitive drawing command GL_DRAW_QUADS_2");
SetupQuad();
break;
case GX_DRAW_TRIANGLES:
SetupTriangle();
break;
Expand Down
32 changes: 20 additions & 12 deletions Source/Core/VideoCommon/IndexGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "Common/Common.h"
#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/VideoConfig.h"

//Init
Expand All @@ -21,22 +22,23 @@ void IndexGenerator::Init()
{
if (g_Config.backend_info.bSupportsPrimitiveRestart)
{
primitive_table[0] = IndexGenerator::AddQuads<true>;
primitive_table[2] = IndexGenerator::AddList<true>;
primitive_table[3] = IndexGenerator::AddStrip<true>;
primitive_table[4] = IndexGenerator::AddFan<true>;
primitive_table[GX_DRAW_QUADS] = IndexGenerator::AddQuads<true>;
primitive_table[GX_DRAW_QUADS_2] = IndexGenerator::AddQuads_nonstandard<true>;
primitive_table[GX_DRAW_TRIANGLES] = IndexGenerator::AddList<true>;
primitive_table[GX_DRAW_TRIANGLE_STRIP] = IndexGenerator::AddStrip<true>;
primitive_table[GX_DRAW_TRIANGLE_FAN] = IndexGenerator::AddFan<true>;
}
else
{
primitive_table[0] = IndexGenerator::AddQuads<false>;
primitive_table[2] = IndexGenerator::AddList<false>;
primitive_table[3] = IndexGenerator::AddStrip<false>;
primitive_table[4] = IndexGenerator::AddFan<false>;
primitive_table[GX_DRAW_QUADS] = IndexGenerator::AddQuads<false>;
primitive_table[GX_DRAW_QUADS_2] = IndexGenerator::AddQuads_nonstandard<false>;
primitive_table[GX_DRAW_TRIANGLES] = IndexGenerator::AddList<false>;
primitive_table[GX_DRAW_TRIANGLE_STRIP] = IndexGenerator::AddStrip<false>;
primitive_table[GX_DRAW_TRIANGLE_FAN] = IndexGenerator::AddFan<false>;
}
primitive_table[1] = nullptr;
primitive_table[5] = &IndexGenerator::AddLineList;
primitive_table[6] = &IndexGenerator::AddLineStrip;
primitive_table[7] = &IndexGenerator::AddPoints;
primitive_table[GX_DRAW_LINES] = &IndexGenerator::AddLineList;
primitive_table[GX_DRAW_LINE_STRIP] = &IndexGenerator::AddLineStrip;
primitive_table[GX_DRAW_POINTS] = &IndexGenerator::AddPoints;
}

void IndexGenerator::Start(u16* Indexptr)
Expand Down Expand Up @@ -196,6 +198,12 @@ template <bool pr> u16* IndexGenerator::AddQuads(u16 *Iptr, u32 numVerts, u32 in
return Iptr;
}

template <bool pr> u16* IndexGenerator::AddQuads_nonstandard(u16 *Iptr, u32 numVerts, u32 index)
{
WARN_LOG(VIDEO, "Non-standard primitive drawing command GL_DRAW_QUADS_2");
return AddQuads<pr>(Iptr, numVerts, index);
}

// Lines
u16* IndexGenerator::AddLineList(u16 *Iptr, u32 numVerts, u32 index)
{
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/IndexGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class IndexGenerator
template <bool pr> static u16* AddStrip(u16 *Iptr, u32 numVerts, u32 index);
template <bool pr> static u16* AddFan(u16 *Iptr, u32 numVerts, u32 index);
template <bool pr> static u16* AddQuads(u16 *Iptr, u32 numVerts, u32 index);
template <bool pr> static u16* AddQuads_nonstandard(u16 *Iptr, u32 numVerts, u32 index);

// Lines
static u16* AddLineList(u16 *Iptr, u32 numVerts, u32 index);
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/VideoCommon/OpcodeDecoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
#define GX_PRIMITIVE_SHIFT 3
#define GX_VAT_MASK 0x07

//these are defined 1/8th of their real values and without their top bit
// These values are the values extracted using GX_PRIMITIVE_MASK
// and GX_PRIMITIVE_SHIFT.
// GX_DRAW_QUADS_2 behaves the same way as GX_DRAW_QUADS.
#define GX_DRAW_QUADS 0x0 // 0x80
#define GX_DRAW_QUADS_2 0x1 // 0x88
#define GX_DRAW_TRIANGLES 0x2 // 0x90
#define GX_DRAW_TRIANGLE_STRIP 0x3 // 0x98
#define GX_DRAW_TRIANGLE_FAN 0x4 // 0xA0
#define GX_DRAW_LINES 0x5 // 0xA8
#define GX_DRAW_LINE_STRIP 0x6 // 0xB0
#define GX_DRAW_POINTS 0x7 // 0xB8
#define GX_DRAW_NONE 0x1; // This is a fake value to used in the backends

extern bool g_bRecordFifoData;

Expand Down
4 changes: 3 additions & 1 deletion Source/Core/VideoCommon/VertexManagerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool VertexManager::IsFlushed;

static const PrimitiveType primitive_from_gx[8] = {
PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS
PRIMITIVE_TRIANGLES, // GX_DRAW_NONE
PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS_2
PRIMITIVE_TRIANGLES, // GX_DRAW_TRIANGLES
PRIMITIVE_TRIANGLES, // GX_DRAW_TRIANGLE_STRIP
PRIMITIVE_TRIANGLES, // GX_DRAW_TRIANGLE_FAN
Expand Down Expand Up @@ -93,6 +93,7 @@ u32 VertexManager::GetRemainingIndices(int primitive)
switch (primitive)
{
case GX_DRAW_QUADS:
case GX_DRAW_QUADS_2:
return index_len / 5 * 4;
case GX_DRAW_TRIANGLES:
return index_len / 4 * 3;
Expand All @@ -118,6 +119,7 @@ u32 VertexManager::GetRemainingIndices(int primitive)
switch (primitive)
{
case GX_DRAW_QUADS:
case GX_DRAW_QUADS_2:
return index_len / 6 * 4;
case GX_DRAW_TRIANGLES:
return index_len;
Expand Down

0 comments on commit 6950f53

Please sign in to comment.