Skip to content

Commit d49937b

Browse files
committed
gxm: move vtx attrib binding to context_flush_dirty_state
Also fixes random crash: ``` deko3d debug callback: context: dkFenceWait, message: Queue (1) entered error state, result 0 deko3d debug callback: context: dkFenceWait, message: timestamp: 0, result 0 deko3d debug callback: context: dkFenceWait, message: info32: 13, result 0 deko3d debug callback: context: dkFenceWait, message: info16: 0, result 0 deko3d debug callback: context: dkFenceWait, message: status: 65535, result 0 deko3d debug callback: context: dkFenceWait, message: --, result 0 deko3d debug callback: context: dkFenceWait, message: GPU method error (irq 0x00100000), result 0 deko3d debug callback: context: dkFenceWait, message: [b197:458] = 0x78800000, result 0 deko3d debug callback: context: dkFenceWait, message: Unknown data: 0x00000000; 0x0000, result 0 ``` `[b197:458]` is `MAXWELL_B` register `NVB197_SET_VERTEX_ATTRIBUTE_A(0)` (https://gitlab.freedesktop.org/mesa/mesa/-/raw/main/src/nouveau/headers/nvidia/classes/clb197.h?ref_type=heads)
1 parent 318a80e commit d49937b

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

source/modules/SceGxm.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,29 +1329,6 @@ EXPORT(SceGxm, 0xB98C5B0D, int, sceGxmDisplayQueueFinish, void)
13291329
EXPORT(SceGxm, 0x31FF8ABD, void, sceGxmSetVertexProgram, SceGxmContext *context,
13301330
const SceGxmVertexProgram *vertexProgram)
13311331
{
1332-
DkVtxAttribState vertex_attrib_state[SCE_GXM_MAX_VERTEX_ATTRIBUTES];
1333-
DkVtxBufferState vertex_buffer_state[SCE_GXM_MAX_VERTEX_STREAMS];
1334-
const SceGxmVertexAttribute *attributes = vertexProgram->attributes;
1335-
const SceGxmVertexStream *streams = vertexProgram->streams;
1336-
1337-
for (uint32_t i = 0; i < vertexProgram->attributeCount; i++) {
1338-
vertex_attrib_state[i].bufferId = attributes[i].streamIndex;
1339-
vertex_attrib_state[i].isFixed = 0;
1340-
vertex_attrib_state[i].offset = attributes[i].offset;
1341-
vertex_attrib_state[i].size =
1342-
gxm_to_dk_vtx_attrib_size(attributes[i].format, attributes[i].componentCount);
1343-
vertex_attrib_state[i].type = gxm_to_dk_vtx_attrib_type(attributes[i].format);
1344-
vertex_attrib_state[i].isBgra = 0;
1345-
}
1346-
1347-
for (uint32_t i = 0; i < vertexProgram->streamCount; i++) {
1348-
vertex_buffer_state[i].stride = streams[i].stride;
1349-
vertex_buffer_state[i].divisor = 0;
1350-
}
1351-
1352-
dkCmdBufBindVtxAttribState(context->cmdbuf, vertex_attrib_state, vertexProgram->attributeCount);
1353-
dkCmdBufBindVtxBufferState(context->cmdbuf, vertex_buffer_state, vertexProgram->streamCount);
1354-
13551332
context->state.vertex_program = vertexProgram;
13561333
context->state.dirty.bit.vertex_shader = true;
13571334
}
@@ -1915,6 +1892,33 @@ static void context_flush_dirty_state(SceGxmContext *context)
19151892
const DkShader *shaders[2];
19161893
const SceGxmVertexProgram *vertex_program = context->state.vertex_program;
19171894
const SceGxmFragmentProgram *fragment_program = context->state.fragment_program;
1895+
const SceGxmVertexAttribute *attributes = vertex_program->attributes;
1896+
const SceGxmVertexStream *streams = vertex_program->streams;
1897+
DkVtxAttribState vertex_attrib_state[SCE_GXM_MAX_VERTEX_ATTRIBUTES];
1898+
DkVtxBufferState vertex_buffer_state[SCE_GXM_MAX_VERTEX_STREAMS];
1899+
uint32_t i;
1900+
1901+
if (context->state.dirty.bit.vertex_shader) {
1902+
for (i = 0; i < vertex_program->attributeCount; i++) {
1903+
vertex_attrib_state[i].bufferId = attributes[i].streamIndex;
1904+
vertex_attrib_state[i].isFixed = 0;
1905+
vertex_attrib_state[i].offset = attributes[i].offset;
1906+
vertex_attrib_state[i].size =
1907+
gxm_to_dk_vtx_attrib_size(attributes[i].format, attributes[i].componentCount);
1908+
vertex_attrib_state[i].type = gxm_to_dk_vtx_attrib_type(attributes[i].format);
1909+
vertex_attrib_state[i].isBgra = 0;
1910+
}
1911+
1912+
for (i = 0; i < vertex_program->streamCount; i++) {
1913+
vertex_buffer_state[i].stride = streams[i].stride;
1914+
vertex_buffer_state[i].divisor = 0;
1915+
}
1916+
1917+
dkCmdBufBindVtxAttribState(context->cmdbuf, vertex_attrib_state,
1918+
vertex_program->attributeCount);
1919+
dkCmdBufBindVtxBufferState(context->cmdbuf, vertex_buffer_state,
1920+
vertex_program->streamCount);
1921+
}
19181922

19191923
if (context->state.dirty.bit.vertex_shader && context->state.dirty.bit.fragment_shader) {
19201924
shaders[0] = &vertex_program->dk_shader;

0 commit comments

Comments
 (0)