summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture/texture_decode.h
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-01-06 04:19:06 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-02-04 21:33:25 +0100
commit09a750e8662e5d4d608177fdfb69b398c3202cd6 (patch)
tree6d5b6af7cd77de75406516eb41eda42f2c963f4a /src/video_core/texture/texture_decode.h
parentVideoCore: Move LookupTexture out of debug_utils.h (diff)
downloadyuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar.gz
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar.bz2
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar.lz
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar.xz
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.tar.zst
yuzu-09a750e8662e5d4d608177fdfb69b398c3202cd6.zip
Diffstat (limited to 'src/video_core/texture/texture_decode.h')
-rw-r--r--src/video_core/texture/texture_decode.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/video_core/texture/texture_decode.h b/src/video_core/texture/texture_decode.h
index 0c1438b0f..5c636939a 100644
--- a/src/video_core/texture/texture_decode.h
+++ b/src/video_core/texture/texture_decode.h
@@ -11,21 +11,29 @@
namespace Pica {
namespace Texture {
+/// Returns the byte size of a 8*8 tile of the specified texture format.
+size_t CalculateTileSize(Pica::Regs::TextureFormat format);
+
struct TextureInfo {
PAddr physical_address;
- int width;
- int height;
- int stride;
+ unsigned int width;
+ unsigned int height;
+ ptrdiff_t stride;
Pica::Regs::TextureFormat format;
static TextureInfo FromPicaRegister(const Pica::Regs::TextureConfig& config,
const Pica::Regs::TextureFormat& format);
+
+ /// Calculates stride from format and width, assuming that the entire texture is contiguous.
+ void SetDefaultStride() {
+ stride = Pica::Texture::CalculateTileSize(format) * (width / 8);
+ }
};
/**
* Lookup texel located at the given coordinates and return an RGBA vector of its color.
* @param source Source pointer to read data from
- * @param s,t Texture coordinates to read from
+ * @param x,y Texture coordinates to read from
* @param info TextureInfo object describing the texture setup
* @param disable_alpha This is used for debug widgets which use this method to display textures
* without providing a good way to visualize alpha by themselves. If true, this will return 255 for
@@ -33,8 +41,20 @@ struct TextureInfo {
* channel.
* @todo Eventually we should get rid of the disable_alpha parameter.
*/
-Math::Vec4<u8> LookupTexture(const u8* source, int s, int t, const TextureInfo& info,
- bool disable_alpha = false);
+Math::Vec4<u8> LookupTexture(const u8* source, unsigned int x, unsigned int y,
+ const TextureInfo& info, bool disable_alpha = false);
+
+/**
+ * Looks up a texel from a single 8x8 texture tile.
+ *
+ * @param source Pointer to the beginning of the tile.
+ * @param x, y In-tile coordinates to read from. Must be < 8.
+ * @param info TextureInfo describing the texture format.
+ * @param disable_alpha Used for debugging. Sets the result alpha to 255 and either discards the
+ * real alpha or inserts it in an otherwise unused channel.
+ */
+Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int y,
+ const TextureInfo& info, bool disable_alpha);
} // namespace Texture
} // namespace Pica