Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nv30_state_emit.c 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include "nv30_context.h"
  2. #include "nv30_state.h"
  3. static struct nv30_state_entry *render_states[] = {
  4. &nv30_state_framebuffer,
  5. &nv30_state_rasterizer,
  6. &nv30_state_scissor,
  7. &nv30_state_stipple,
  8. &nv30_state_fragprog,
  9. &nv30_state_fragtex,
  10. &nv30_state_vertprog,
  11. &nv30_state_blend,
  12. &nv30_state_blend_colour,
  13. &nv30_state_zsa,
  14. &nv30_state_sr,
  15. &nv30_state_viewport,
  16. &nv30_state_vbo,
  17. NULL
  18. };
  19. static void
  20. nv30_state_do_validate(struct nv30_context *nv30,
  21. struct nv30_state_entry **states)
  22. {
  23. while (*states) {
  24. struct nv30_state_entry *e = *states;
  25. if (nv30->dirty & e->dirty.pipe) {
  26. if (e->validate(nv30)) {
  27. nv30->state.dirty |= (1ULL << e->dirty.hw);
  28. }
  29. }
  30. states++;
  31. }
  32. nv30->dirty = 0;
  33. }
  34. void
  35. nv30_state_emit(struct nv30_context *nv30)
  36. {
  37. struct nouveau_channel *chan = nv30->screen->base.channel;
  38. struct nv30_state *state = &nv30->state;
  39. struct nv30_screen *screen = nv30->screen;
  40. unsigned i;
  41. uint64_t states;
  42. /* XXX: racy!
  43. */
  44. if (nv30 != screen->cur_ctx) {
  45. for (i = 0; i < NV30_STATE_MAX; i++) {
  46. if (state->hw[i] && screen->state[i] != state->hw[i])
  47. state->dirty |= (1ULL << i);
  48. }
  49. screen->cur_ctx = nv30;
  50. }
  51. for (i = 0, states = state->dirty; states; i++) {
  52. if (!(states & (1ULL << i)))
  53. continue;
  54. so_ref (state->hw[i], &nv30->screen->state[i]);
  55. if (state->hw[i])
  56. so_emit(chan, nv30->screen->state[i]);
  57. states &= ~(1ULL << i);
  58. }
  59. state->dirty = 0;
  60. }
  61. void
  62. nv30_state_flush_notify(struct nouveau_channel *chan)
  63. {
  64. struct nv30_context *nv30 = chan->user_private;
  65. struct nv30_state *state = &nv30->state;
  66. unsigned i, samplers;
  67. so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]);
  68. for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
  69. if (!(samplers & (1 << i)))
  70. continue;
  71. so_emit_reloc_markers(chan,
  72. state->hw[NV30_STATE_FRAGTEX0+i]);
  73. samplers &= ~(1ULL << i);
  74. }
  75. so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGPROG]);
  76. if (state->hw[NV30_STATE_VTXBUF] /*&& nv30->render_mode == HW*/)
  77. so_emit_reloc_markers(chan, state->hw[NV30_STATE_VTXBUF]);
  78. }
  79. boolean
  80. nv30_state_validate(struct nv30_context *nv30)
  81. {
  82. #if 0
  83. boolean was_sw = nv30->fallback_swtnl ? TRUE : FALSE;
  84. if (nv30->render_mode != HW) {
  85. /* Don't even bother trying to go back to hw if none
  86. * of the states that caused swtnl previously have changed.
  87. */
  88. if ((nv30->fallback_swtnl & nv30->dirty)
  89. != nv30->fallback_swtnl)
  90. return FALSE;
  91. /* Attempt to go to hwtnl again */
  92. nv30->pipe.flush(&nv30->pipe, 0, NULL);
  93. nv30->dirty |= (NV30_NEW_VIEWPORT |
  94. NV30_NEW_VERTPROG |
  95. NV30_NEW_ARRAYS);
  96. nv30->render_mode = HW;
  97. }
  98. #endif
  99. nv30_state_do_validate(nv30, render_states);
  100. #if 0
  101. if (nv30->fallback_swtnl || nv30->fallback_swrast)
  102. return FALSE;
  103. if (was_sw)
  104. NOUVEAU_ERR("swtnl->hw\n");
  105. #endif
  106. return TRUE;
  107. }