Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include <assert.h>
- static void parse_vs_draw(uint32_t *value1, uint32_t *value2)
- {
- printf("\tDRAW: num_1: %d (0x%x), index_draw: %s, num_2: %d (0x%x)\n",
- *value1 >> 24, *value1 >> 24,
- (*value2 & 0x00000001) ? "enabled" : "disabled",
- (*value2 & 0xfffffffe) << 8, (*value2 & 0xfffffffe) << 8);
- }
- static void parse_vs_shader_info(uint32_t *value1, uint32_t *value2)
- {
- printf("\tSHADER_INFO: prefetch: %s, size: %d (0x%x)\n",
- (*value1 & 0x00100000) ? "enabled" : "disabled",
- (((*value1 & 0x000fffff) >> 10) + 1) << 4,
- (((*value1 & 0x000fffff) >> 10) + 1) << 4);
- }
- static void parse_vs_unknown1(uint32_t *value1, uint32_t *value2)
- {
- printf("\tUNKNOWN_1\n");
- }
- static void parse_vs_varying_attribute_count(uint32_t *value1, uint32_t *value2)
- {
- printf("\tVARYING_ATTRIBUTE_COUNT: nr_vary: %d (0x%x), nr_attr: %d (0x%x)\n",
- ((*value1 & 0x00ffffff) >> 8) + 1, ((*value1 & 0x00ffffff) >> 8) + 1,
- (*value1 >> 24) + 1, (*value1 >> 24) + 1);
- }
- static void parse_vs_attributes_address(uint32_t *value1, uint32_t *value2)
- {
- printf("\tATTRIBUTES_ADDRESS: address: 0x%08x, size: %d (0x%x)\n",
- *value1, (*value2 & 0x0fffffff) >> 17, (*value2 & 0x0fffffff) >> 17);
- }
- static void parse_vs_varyings_address(uint32_t *value1, uint32_t *value2)
- {
- printf("\tVARYINGS_ADDRESS: address: 0x%08x, size: %d (0x%x)\n",
- *value1, (*value2 & 0x0fffffff) >> 17, (*value2 & 0x0fffffff) >> 17);
- }
- static void parse_vs_uniforms_address(uint32_t *value1, uint32_t *value2)
- {
- printf("\tUNIFORMS_ADDRESS: address: 0x%08x, size: %d (0x%x)\n",
- *value1, (*value2 & 0x0fffffff) >> 12, (*value2 & 0x0fffffff) >> 12);
- }
- static void parse_vs_shader_address(uint32_t *value1, uint32_t *value2)
- {
- printf("\tSHADER_ADDRESS: address: 0x%08x, size: %d (0x%x)\n",
- *value1, (*value2 & 0x0fffffff) >> 12, (*value2 & 0x0fffffff) >> 12);
- }
- static void parse_vs_semaphore(uint32_t *value1, uint32_t *value2)
- {
- if (*value1 == 0x00028000)
- printf("\tSEMAPHORE_BEGIN_1\n");
- else if (*value1 == 0x00000001)
- printf("\tSEMAPHORE_BEGIN_2\n");
- else if (*value1 == 0x00000000)
- printf("\tSEMAPHORE_END: index_draw disabled\n");
- else if (*value1 == 0x00018000)
- printf("\tSEMAPHORE_END: index_draw disabled\n");
- else
- printf("\tSEMAPHORE - cmd unknown!\n");
- }
- static void parse_vs_unknown2(uint32_t *value1, uint32_t *value2)
- {
- printf("\tUNKNOWN_2\n");
- }
- void parse_vs(uint32_t desc[], int size_i)
- {
- uint32_t *value1;
- uint32_t *value2;
- printf("============ VS CMD STREAM BEGIN =============\n");
- for (int i = 0; i < (size_i / 4) - 1; i = i + 2) {
- value1 = &desc[i];
- value2 = &desc[i + 1];
- printf("/* 0x%08x */\t0x%08x 0x%08x", i * 4, *value1, *value2);
- if ((*value2 & 0xffff0000) == 0x00000000)
- parse_vs_draw(value1, value2);
- else if ((*value2 & 0xff0000ff) == 0x10000040)
- parse_vs_shader_info(value1, value2);
- else if ((*value2 & 0xff0000ff) == 0x10000041)
- parse_vs_unknown1(value1, value2);
- else if ((*value2 & 0xff0000ff) == 0x10000042)
- parse_vs_varying_attribute_count(value1, value2);
- else if ((*value2 & 0xff0000ff) == 0x20000000)
- parse_vs_attributes_address(value1, value2);
- else if ((*value2 & 0xff0000ff) == 0x20000008)
- parse_vs_varyings_address(value1, value2);
- else if ((*value2 & 0xff000000) == 0x30000000)
- parse_vs_uniforms_address(value1, value2);
- else if ((*value2 & 0xff000000) == 0x40000000)
- parse_vs_shader_address(value1, value2);
- else if ((*value2 & 0xff000000)== 0x50000000)
- parse_vs_semaphore(value1, value2);
- else if ((*value2 & 0xff000000) == 0x60000000)
- parse_vs_unknown2(value1, value2);
- else
- printf("\t--- unknown cmd ---\n");
- }
- printf("============ VS CMD STREAM END ===============\n");
- }
- int main(void)
- {
- /* Mali blob */
- uint32_t desc_i[] = {
- 0x00028000, 0x50000000, 0x00000001, 0x50000000, /* 0x00000000 */
- 0x10014480, 0x30040000, 0x10000100, 0x40050000, /* 0x00000010 */
- 0x00001000, 0x10000040, 0x00000100, 0x10000042, /* 0x00000020 */
- 0x00000003, 0x10000041, 0x100144c0, 0x20020000, /* 0x00000030 */
- 0x100144d0, 0x20040008, 0x01000000, 0x00000000, /* 0x00000040 */
- 0x00000000, 0x60000000, 0x00000000, 0x50000000, /* 0x00000050 */
- };
- parse_vs(desc_i, sizeof(desc_i));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment