<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wyatt</id>
	<title>3dbrew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wyatt"/>
	<link rel="alternate" type="text/html" href="https://www.3dbrew.org/wiki/Special:Contributions/Wyatt"/>
	<updated>2026-05-02T15:19:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=GPU/Pitfalls&amp;diff=23703</id>
		<title>GPU/Pitfalls</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=GPU/Pitfalls&amp;diff=23703"/>
		<updated>2025-11-01T21:39:06Z</updated>

		<summary type="html">&lt;p&gt;Wyatt: Document L4-format texture crash&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page collects some oddities and pitfalls of the PICA GPU which is used in the 3DS.&lt;br /&gt;
&lt;br /&gt;
[[Category:GPU]]&lt;br /&gt;
&lt;br /&gt;
== Internal Registers ==&lt;br /&gt;
&lt;br /&gt;
=== Vertex attribute alignment ===&lt;br /&gt;
&lt;br /&gt;
Vertex components which are defined through [[GPU/Internal_Registers#GPUREG_ATTRIBBUFFERi_CONFIG1|GPUREG_ATTRIBBUFFERi_CONFIG1]] will be accessed aligned by the GPU.&lt;br /&gt;
* Vertex attributes will be aligned to their component element size.&lt;br /&gt;
* Padding attributes (Component type &amp;gt; 11) will always aligned to 4 byte offets into the buffer.&lt;br /&gt;
* The stride which is passed to the GPU should be passed unaligned.&lt;br /&gt;
&lt;br /&gt;
=== Vertex stride in GPUREG_ATTRIBBUFFERi_CONFIG2 ===&lt;br /&gt;
&lt;br /&gt;
The vertex stride set in [[GPU/Internal_Registers#GPUREG_ATTRIBBUFFERi_CONFIG2|GPUREG_ATTRIBBUFFERi_CONFIG2]] must match the actual size of the vertex contained in the buffer or the PICA will freeze or it won&#039;t draw anything.&lt;br /&gt;
&lt;br /&gt;
If you want to use a different stride you have to pad the data accordingly with padding attributes.&lt;br /&gt;
&lt;br /&gt;
=== Output mapping in GPUREG_SH_OUTMAP_MASK ===&lt;br /&gt;
&lt;br /&gt;
The output masking in [[GPU/Internal_Registers#GPUREG_SH_OUTMAP_MASK|GPUREG_SH_OUTMAP_MASK]] influences how the registers starting at [[GPU/Internal_Registers#GPUREG_SH_OUTMAP_Oi|GPUREG_SH_OUTMAP_Oi]] map to outputs in the shader.&lt;br /&gt;
&lt;br /&gt;
If an output is disabled in [[GPU/Internal_Registers#GPUREG_SH_OUTMAP_MASK|GPUREG_SH_OUTMAP_MASK]] it means that no slot in the [[GPU/Internal_Registers#GPUREG_SH_OUTMAP_Oi|GPUREG_SH_OUTMAP_Oi]] registers is consumed.&lt;br /&gt;
[[GPU/Internal_Registers#GPUREG_SH_OUTMAP_TOTAL|GPUREG_SH_OUTMAP_TOTAL]] configures the number of used consecutive slots in the outmap.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Register&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
|GPUREG_SH_OUTMAP_TOTAL&lt;br /&gt;
|0x00000002&lt;br /&gt;
|2 outputs enabled&lt;br /&gt;
|-&lt;br /&gt;
|GPUREG_SH_OUTMAP_MASK&lt;br /&gt;
|0x00000011&lt;br /&gt;
|o0 enabled, o4 enabled&lt;br /&gt;
|-&lt;br /&gt;
|GPUREG_SH_OUTMAP_O0&lt;br /&gt;
|0x03020100&lt;br /&gt;
|o0 = pos.xyzw&lt;br /&gt;
|-&lt;br /&gt;
|GPUREG_SH_OUTMAP_O1&lt;br /&gt;
|0x0B0A0908&lt;br /&gt;
|o4 = color.rgba&lt;br /&gt;
|-&lt;br /&gt;
|GPUREG_SH_OUTMAP_O2&lt;br /&gt;
|...&lt;br /&gt;
|(unused)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TEXUNIT1 Corruption and Instability ===&lt;br /&gt;
&lt;br /&gt;
If an L4-formatted texture (or likely any 4-bit texture format) located within VRAM is bound to TEXUNIT1, the PICA can become unstable, usually freezing after a seemingly random amount of time. If that texture is 8x16 or larger, the GPU will also display corrupt visuals until the console is rebooted; this will even persist in other software. Unbinding the texture makes the console stable again, but doesn&#039;t fix the visuals, though the severity of the corruption is slightly reduced because the exact results also depend on the texture data. Notably, this does not seem to occur with other TEXUNITs or with textures located in FCRAM. This could use more investigation.&lt;br /&gt;
&lt;br /&gt;
Writer&#039;s Note: I struggled for days to reproduce this. I happened across it in a real application, and swapping between L4 and L8 affected the issue with 100% consistency. I then went to make this write-up months later and made a test program to reproduce the bug, which worked as expected. Like a doofus I rewrote the program a bit to test a bit more thoroughly, somehow caused the bug to stop occurring, and haven&#039;t been able to reproduce it since. Needs further investigation.&lt;br /&gt;
&lt;br /&gt;
== Shaders ==&lt;br /&gt;
&lt;br /&gt;
=== Configued Output components must be written exactly once ===&lt;br /&gt;
&lt;br /&gt;
Each configured output component has to be written exactly once or the PICA freezes.&lt;br /&gt;
&lt;br /&gt;
=== MOVA instructions can&#039;t be adjacent ===&lt;br /&gt;
&lt;br /&gt;
Having 2 consecutive MOVA instructions will freeze the PICA. This can be relaxed by placing a NOP between 2 MOVAs or by rearranging the code.&lt;/div&gt;</summary>
		<author><name>Wyatt</name></author>
	</entry>
</feed>