Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

draw_context.c 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /**************************************************************************
  2. *
  3. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. /*
  28. * Authors:
  29. * Keith Whitwell <keith@tungstengraphics.com>
  30. */
  31. #include "pipe/p_context.h"
  32. #include "util/u_memory.h"
  33. #include "util/u_math.h"
  34. #include "util/u_cpu_detect.h"
  35. #include "draw_context.h"
  36. #include "draw_vs.h"
  37. #include "draw_gs.h"
  38. #if HAVE_LLVM
  39. #include "gallivm/lp_bld_init.h"
  40. #include "draw_llvm.h"
  41. static boolean
  42. draw_get_option_use_llvm(void)
  43. {
  44. static boolean first = TRUE;
  45. static boolean value;
  46. if (first) {
  47. first = FALSE;
  48. value = debug_get_bool_option("DRAW_USE_LLVM", TRUE);
  49. #ifdef PIPE_ARCH_X86
  50. util_cpu_detect();
  51. /* require SSE2 due to LLVM PR6960. */
  52. if (!util_cpu_caps.has_sse2)
  53. value = FALSE;
  54. #endif
  55. }
  56. return value;
  57. }
  58. #endif
  59. struct draw_context *draw_create( struct pipe_context *pipe )
  60. {
  61. struct draw_context *draw = CALLOC_STRUCT( draw_context );
  62. if (draw == NULL)
  63. goto fail;
  64. #if HAVE_LLVM
  65. if(draw_get_option_use_llvm())
  66. {
  67. lp_build_init();
  68. assert(lp_build_engine);
  69. draw->engine = lp_build_engine;
  70. draw->llvm = draw_llvm_create(draw);
  71. }
  72. #endif
  73. if (!draw_init(draw))
  74. goto fail;
  75. draw->pipe = pipe;
  76. return draw;
  77. fail:
  78. draw_destroy( draw );
  79. return NULL;
  80. }
  81. boolean draw_init(struct draw_context *draw)
  82. {
  83. /*
  84. * Note that several functions compute the clipmask of the predefined
  85. * formats with hardcoded formulas instead of using these. So modifications
  86. * here must be reflected there too.
  87. */
  88. ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 );
  89. ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 );
  90. ASSIGN_4V( draw->plane[2], 0, -1, 0, 1 );
  91. ASSIGN_4V( draw->plane[3], 0, 1, 0, 1 );
  92. ASSIGN_4V( draw->plane[4], 0, 0, 1, 1 ); /* yes these are correct */
  93. ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */
  94. draw->nr_planes = 6;
  95. draw->clip_xy = 1;
  96. draw->clip_z = 1;
  97. draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
  98. if (!draw_pipeline_init( draw ))
  99. return FALSE;
  100. if (!draw_pt_init( draw ))
  101. return FALSE;
  102. if (!draw_vs_init( draw ))
  103. return FALSE;
  104. if (!draw_gs_init( draw ))
  105. return FALSE;
  106. return TRUE;
  107. }
  108. void draw_destroy( struct draw_context *draw )
  109. {
  110. struct pipe_context *pipe;
  111. int i, j;
  112. if (!draw)
  113. return;
  114. pipe = draw->pipe;
  115. /* free any rasterizer CSOs that we may have created.
  116. */
  117. for (i = 0; i < 2; i++) {
  118. for (j = 0; j < 2; j++) {
  119. if (draw->rasterizer_no_cull[i][j]) {
  120. pipe->delete_rasterizer_state(pipe, draw->rasterizer_no_cull[i][j]);
  121. }
  122. }
  123. }
  124. /* Not so fast -- we're just borrowing this at the moment.
  125. *
  126. if (draw->render)
  127. draw->render->destroy( draw->render );
  128. */
  129. draw_pipeline_destroy( draw );
  130. draw_pt_destroy( draw );
  131. draw_vs_destroy( draw );
  132. draw_gs_destroy( draw );
  133. #ifdef HAVE_LLVM
  134. if(draw->llvm)
  135. draw_llvm_destroy( draw->llvm );
  136. #endif
  137. FREE( draw );
  138. }
  139. void draw_flush( struct draw_context *draw )
  140. {
  141. draw_do_flush( draw, DRAW_FLUSH_BACKEND );
  142. }
  143. /**
  144. * Specify the Minimum Resolvable Depth factor for polygon offset.
  145. * This factor potentially depends on the number of Z buffer bits,
  146. * the rasterization algorithm and the arithmetic performed on Z
  147. * values between vertex shading and rasterization. It will vary
  148. * from one driver to another.
  149. */
  150. void draw_set_mrd(struct draw_context *draw, double mrd)
  151. {
  152. draw->mrd = mrd;
  153. }
  154. static void update_clip_flags( struct draw_context *draw )
  155. {
  156. draw->clip_xy = !draw->driver.bypass_clip_xy;
  157. draw->clip_z = (!draw->driver.bypass_clip_z &&
  158. !draw->depth_clamp);
  159. draw->clip_user = (draw->nr_planes > 6);
  160. }
  161. /**
  162. * Register new primitive rasterization/rendering state.
  163. * This causes the drawing pipeline to be rebuilt.
  164. */
  165. void draw_set_rasterizer_state( struct draw_context *draw,
  166. const struct pipe_rasterizer_state *raster,
  167. void *rast_handle )
  168. {
  169. if (!draw->suspend_flushing) {
  170. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  171. draw->rasterizer = raster;
  172. draw->rast_handle = rast_handle;
  173. }
  174. }
  175. /* With a little more work, llvmpipe will be able to turn this off and
  176. * do its own x/y clipping.
  177. *
  178. * Some hardware can turn off clipping altogether - in particular any
  179. * hardware with a TNL unit can do its own clipping, even if it is
  180. * relying on the draw module for some other reason.
  181. */
  182. void draw_set_driver_clipping( struct draw_context *draw,
  183. boolean bypass_clip_xy,
  184. boolean bypass_clip_z )
  185. {
  186. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  187. draw->driver.bypass_clip_xy = bypass_clip_xy;
  188. draw->driver.bypass_clip_z = bypass_clip_z;
  189. update_clip_flags(draw);
  190. }
  191. /**
  192. * Plug in the primitive rendering/rasterization stage (which is the last
  193. * stage in the drawing pipeline).
  194. * This is provided by the device driver.
  195. */
  196. void draw_set_rasterize_stage( struct draw_context *draw,
  197. struct draw_stage *stage )
  198. {
  199. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  200. draw->pipeline.rasterize = stage;
  201. }
  202. /**
  203. * Set the draw module's clipping state.
  204. */
  205. void draw_set_clip_state( struct draw_context *draw,
  206. const struct pipe_clip_state *clip )
  207. {
  208. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  209. assert(clip->nr <= PIPE_MAX_CLIP_PLANES);
  210. memcpy(&draw->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0]));
  211. draw->nr_planes = 6 + clip->nr;
  212. draw->depth_clamp = clip->depth_clamp;
  213. update_clip_flags(draw);
  214. }
  215. /**
  216. * Set the draw module's viewport state.
  217. */
  218. void draw_set_viewport_state( struct draw_context *draw,
  219. const struct pipe_viewport_state *viewport )
  220. {
  221. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  222. draw->viewport = *viewport; /* struct copy */
  223. draw->identity_viewport = (viewport->scale[0] == 1.0f &&
  224. viewport->scale[1] == 1.0f &&
  225. viewport->scale[2] == 1.0f &&
  226. viewport->scale[3] == 1.0f &&
  227. viewport->translate[0] == 0.0f &&
  228. viewport->translate[1] == 0.0f &&
  229. viewport->translate[2] == 0.0f &&
  230. viewport->translate[3] == 0.0f);
  231. draw_vs_set_viewport( draw, viewport );
  232. }
  233. void
  234. draw_set_vertex_buffers(struct draw_context *draw,
  235. unsigned count,
  236. const struct pipe_vertex_buffer *buffers)
  237. {
  238. assert(count <= PIPE_MAX_ATTRIBS);
  239. memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0]));
  240. draw->pt.nr_vertex_buffers = count;
  241. }
  242. void
  243. draw_set_vertex_elements(struct draw_context *draw,
  244. unsigned count,
  245. const struct pipe_vertex_element *elements)
  246. {
  247. assert(count <= PIPE_MAX_ATTRIBS);
  248. memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0]));
  249. draw->pt.nr_vertex_elements = count;
  250. }
  251. /**
  252. * Tell drawing context where to find mapped vertex buffers.
  253. */
  254. void
  255. draw_set_mapped_vertex_buffer(struct draw_context *draw,
  256. unsigned attr, const void *buffer)
  257. {
  258. draw->pt.user.vbuffer[attr] = buffer;
  259. }
  260. void
  261. draw_set_mapped_constant_buffer(struct draw_context *draw,
  262. unsigned shader_type,
  263. unsigned slot,
  264. const void *buffer,
  265. unsigned size )
  266. {
  267. debug_assert(shader_type == PIPE_SHADER_VERTEX ||
  268. shader_type == PIPE_SHADER_GEOMETRY);
  269. debug_assert(slot < PIPE_MAX_CONSTANT_BUFFERS);
  270. switch (shader_type) {
  271. case PIPE_SHADER_VERTEX:
  272. draw->pt.user.vs_constants[slot] = buffer;
  273. draw->pt.user.vs_constants_size[slot] = size;
  274. draw_vs_set_constants(draw, slot, buffer, size);
  275. break;
  276. case PIPE_SHADER_GEOMETRY:
  277. draw->pt.user.gs_constants[slot] = buffer;
  278. draw->pt.user.gs_constants_size[slot] = size;
  279. draw_gs_set_constants(draw, slot, buffer, size);
  280. break;
  281. default:
  282. assert(0 && "invalid shader type in draw_set_mapped_constant_buffer");
  283. }
  284. }
  285. /**
  286. * Tells the draw module to draw points with triangles if their size
  287. * is greater than this threshold.
  288. */
  289. void
  290. draw_wide_point_threshold(struct draw_context *draw, float threshold)
  291. {
  292. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  293. draw->pipeline.wide_point_threshold = threshold;
  294. }
  295. /**
  296. * Should the draw module handle point->quad conversion for drawing sprites?
  297. */
  298. void
  299. draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite)
  300. {
  301. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  302. draw->pipeline.wide_point_sprites = draw_sprite;
  303. }
  304. /**
  305. * Tells the draw module to draw lines with triangles if their width
  306. * is greater than this threshold.
  307. */
  308. void
  309. draw_wide_line_threshold(struct draw_context *draw, float threshold)
  310. {
  311. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  312. draw->pipeline.wide_line_threshold = threshold;
  313. }
  314. /**
  315. * Tells the draw module whether or not to implement line stipple.
  316. */
  317. void
  318. draw_enable_line_stipple(struct draw_context *draw, boolean enable)
  319. {
  320. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  321. draw->pipeline.line_stipple = enable;
  322. }
  323. /**
  324. * Tells draw module whether to convert points to quads for sprite mode.
  325. */
  326. void
  327. draw_enable_point_sprites(struct draw_context *draw, boolean enable)
  328. {
  329. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  330. draw->pipeline.point_sprite = enable;
  331. }
  332. void
  333. draw_set_force_passthrough( struct draw_context *draw, boolean enable )
  334. {
  335. draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  336. draw->force_passthrough = enable;
  337. }
  338. /**
  339. * Allocate an extra vertex/geometry shader vertex attribute.
  340. * This is used by some of the optional draw module stages such
  341. * as wide_point which may need to allocate additional generic/texcoord
  342. * attributes.
  343. */
  344. int
  345. draw_alloc_extra_vertex_attrib(struct draw_context *draw,
  346. uint semantic_name, uint semantic_index)
  347. {
  348. const int num_outputs = draw_current_shader_outputs(draw);
  349. const int n = draw->extra_shader_outputs.num;
  350. assert(n < Elements(draw->extra_shader_outputs.semantic_name));
  351. draw->extra_shader_outputs.semantic_name[n] = semantic_name;
  352. draw->extra_shader_outputs.semantic_index[n] = semantic_index;
  353. draw->extra_shader_outputs.slot[n] = num_outputs + n;
  354. draw->extra_shader_outputs.num++;
  355. return draw->extra_shader_outputs.slot[n];
  356. }
  357. /**
  358. * Remove all extra vertex attributes that were allocated with
  359. * draw_alloc_extra_vertex_attrib().
  360. */
  361. void
  362. draw_remove_extra_vertex_attribs(struct draw_context *draw)
  363. {
  364. draw->extra_shader_outputs.num = 0;
  365. }
  366. /**
  367. * Ask the draw module for the location/slot of the given vertex attribute in
  368. * a post-transformed vertex.
  369. *
  370. * With this function, drivers that use the draw module should have no reason
  371. * to track the current vertex/geometry shader.
  372. *
  373. * Note that the draw module may sometimes generate vertices with extra
  374. * attributes (such as texcoords for AA lines). The driver can call this
  375. * function to find those attributes.
  376. *
  377. * Zero is returned if the attribute is not found since this is
  378. * a don't care / undefined situtation. Returning -1 would be a bit more
  379. * work for the drivers.
  380. */
  381. int
  382. draw_find_shader_output(const struct draw_context *draw,
  383. uint semantic_name, uint semantic_index)
  384. {
  385. const struct draw_vertex_shader *vs = draw->vs.vertex_shader;
  386. const struct draw_geometry_shader *gs = draw->gs.geometry_shader;
  387. uint i;
  388. const struct tgsi_shader_info *info = &vs->info;
  389. if (gs)
  390. info = &gs->info;
  391. for (i = 0; i < info->num_outputs; i++) {
  392. if (info->output_semantic_name[i] == semantic_name &&
  393. info->output_semantic_index[i] == semantic_index)
  394. return i;
  395. }
  396. /* Search the extra vertex attributes */
  397. for (i = 0; i < draw->extra_shader_outputs.num; i++) {
  398. if (draw->extra_shader_outputs.semantic_name[i] == semantic_name &&
  399. draw->extra_shader_outputs.semantic_index[i] == semantic_index) {
  400. return draw->extra_shader_outputs.slot[i];
  401. }
  402. }
  403. return 0;
  404. }
  405. /**
  406. * Return total number of the shader outputs. This function is similar to
  407. * draw_current_shader_outputs() but this function also counts any extra
  408. * vertex/geometry output attributes that may be filled in by some draw
  409. * stages (such as AA point, AA line).
  410. *
  411. * If geometry shader is present, its output will be returned,
  412. * if not vertex shader is used.
  413. */
  414. uint
  415. draw_num_shader_outputs(const struct draw_context *draw)
  416. {
  417. uint count;
  418. /* If a geometry shader is present, its outputs go to the
  419. * driver, else the vertex shader's outputs.
  420. */
  421. if (draw->gs.geometry_shader)
  422. count = draw->gs.geometry_shader->info.num_outputs;
  423. else
  424. count = draw->vs.vertex_shader->info.num_outputs;
  425. count += draw->extra_shader_outputs.num;
  426. return count;
  427. }
  428. /**
  429. * Provide TGSI sampler objects for vertex/geometry shaders that use
  430. * texture fetches.
  431. * This might only be used by software drivers for the time being.
  432. */
  433. void
  434. draw_texture_samplers(struct draw_context *draw,
  435. uint shader,
  436. uint num_samplers,
  437. struct tgsi_sampler **samplers)
  438. {
  439. if (shader == PIPE_SHADER_VERTEX) {
  440. draw->vs.num_samplers = num_samplers;
  441. draw->vs.samplers = samplers;
  442. } else {
  443. debug_assert(shader == PIPE_SHADER_GEOMETRY);
  444. draw->gs.num_samplers = num_samplers;
  445. draw->gs.samplers = samplers;
  446. }
  447. }
  448. void draw_set_render( struct draw_context *draw,
  449. struct vbuf_render *render )
  450. {
  451. draw->render = render;
  452. }
  453. void
  454. draw_set_index_buffer(struct draw_context *draw,
  455. const struct pipe_index_buffer *ib)
  456. {
  457. if (ib)
  458. memcpy(&draw->pt.index_buffer, ib, sizeof(draw->pt.index_buffer));
  459. else
  460. memset(&draw->pt.index_buffer, 0, sizeof(draw->pt.index_buffer));
  461. }
  462. /**
  463. * Tell drawing context where to find mapped index/element buffer.
  464. */
  465. void
  466. draw_set_mapped_index_buffer(struct draw_context *draw,
  467. const void *elements)
  468. {
  469. draw->pt.user.elts = elements;
  470. }
  471. /* Revamp me please:
  472. */
  473. void draw_do_flush( struct draw_context *draw, unsigned flags )
  474. {
  475. if (!draw->suspend_flushing)
  476. {
  477. assert(!draw->flushing); /* catch inadvertant recursion */
  478. draw->flushing = TRUE;
  479. draw_pipeline_flush( draw, flags );
  480. draw->reduced_prim = ~0; /* is reduced_prim needed any more? */
  481. draw->flushing = FALSE;
  482. }
  483. }
  484. /**
  485. * Return the number of output attributes produced by the geometry
  486. * shader, if present. If no geometry shader, return the number of
  487. * outputs from the vertex shader.
  488. * \sa draw_num_shader_outputs
  489. */
  490. uint
  491. draw_current_shader_outputs(const struct draw_context *draw)
  492. {
  493. if (draw->gs.geometry_shader)
  494. return draw->gs.num_gs_outputs;
  495. return draw->vs.num_vs_outputs;
  496. }
  497. /**
  498. * Return the index of the shader output which will contain the
  499. * vertex position.
  500. */
  501. uint
  502. draw_current_shader_position_output(const struct draw_context *draw)
  503. {
  504. if (draw->gs.geometry_shader)
  505. return draw->gs.position_output;
  506. return draw->vs.position_output;
  507. }
  508. /**
  509. * Return a pointer/handle for a driver/CSO rasterizer object which
  510. * disabled culling, stippling, unfilled tris, etc.
  511. * This is used by some pipeline stages (such as wide_point, aa_line
  512. * and aa_point) which convert points/lines into triangles. In those
  513. * cases we don't want to accidentally cull the triangles.
  514. *
  515. * \param scissor should the rasterizer state enable scissoring?
  516. * \param flatshade should the rasterizer state use flat shading?
  517. * \return rasterizer CSO handle
  518. */
  519. void *
  520. draw_get_rasterizer_no_cull( struct draw_context *draw,
  521. boolean scissor,
  522. boolean flatshade )
  523. {
  524. if (!draw->rasterizer_no_cull[scissor][flatshade]) {
  525. /* create now */
  526. struct pipe_context *pipe = draw->pipe;
  527. struct pipe_rasterizer_state rast;
  528. memset(&rast, 0, sizeof(rast));
  529. rast.scissor = scissor;
  530. rast.flatshade = flatshade;
  531. rast.front_ccw = 1;
  532. rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules;
  533. draw->rasterizer_no_cull[scissor][flatshade] =
  534. pipe->create_rasterizer_state(pipe, &rast);
  535. }
  536. return draw->rasterizer_no_cull[scissor][flatshade];
  537. }
  538. void
  539. draw_set_mapped_so_buffers(struct draw_context *draw,
  540. void *buffers[PIPE_MAX_SO_BUFFERS],
  541. unsigned num_buffers)
  542. {
  543. int i;
  544. for (i = 0; i < num_buffers; ++i) {
  545. draw->so.buffers[i] = buffers[i];
  546. }
  547. draw->so.num_buffers = num_buffers;
  548. }
  549. void
  550. draw_set_so_state(struct draw_context *draw,
  551. struct pipe_stream_output_state *state)
  552. {
  553. memcpy(&draw->so.state,
  554. state,
  555. sizeof(struct pipe_stream_output_state));
  556. }
  557. void
  558. draw_set_sampler_views(struct draw_context *draw,
  559. struct pipe_sampler_view **views,
  560. unsigned num)
  561. {
  562. unsigned i;
  563. debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
  564. for (i = 0; i < num; ++i)
  565. draw->sampler_views[i] = views[i];
  566. for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
  567. draw->sampler_views[i] = NULL;
  568. draw->num_sampler_views = num;
  569. }
  570. void
  571. draw_set_samplers(struct draw_context *draw,
  572. struct pipe_sampler_state **samplers,
  573. unsigned num)
  574. {
  575. unsigned i;
  576. debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
  577. for (i = 0; i < num; ++i)
  578. draw->samplers[i] = samplers[i];
  579. for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
  580. draw->samplers[i] = NULL;
  581. draw->num_samplers = num;
  582. #ifdef HAVE_LLVM
  583. if (draw->llvm)
  584. draw_llvm_set_sampler_state(draw);
  585. #endif
  586. }
  587. void
  588. draw_set_mapped_texture(struct draw_context *draw,
  589. unsigned sampler_idx,
  590. uint32_t width, uint32_t height, uint32_t depth,
  591. uint32_t last_level,
  592. uint32_t row_stride[DRAW_MAX_TEXTURE_LEVELS],
  593. uint32_t img_stride[DRAW_MAX_TEXTURE_LEVELS],
  594. const void *data[DRAW_MAX_TEXTURE_LEVELS])
  595. {
  596. #ifdef HAVE_LLVM
  597. if(draw->llvm)
  598. draw_llvm_set_mapped_texture(draw,
  599. sampler_idx,
  600. width, height, depth, last_level,
  601. row_stride, img_stride, data);
  602. #endif
  603. }