Page MenuHome

fixes wrong texture limit for OpenCL in Cycles

Authored by mathieu menuet (bliblubli) on Sep 25 2015, 9:17 PM.



OpenCL has actually no limitation regarding the numbers of textures. This patch however limits it to 235 as it was the max that could fit in memory of a 7750 (the lowest end card that is faster than a CPU) using the pixar library. Using lower res texture certainly would allow more to fit in and most people will render with higher end cards. But it's a safe patch that could be included in 2.76. Tested on 7750, 7770, 280x and 390x on many scenes and scenes specifically made for this patch. The 390x could render with more than 1024 textures by the way in our test.
We are using this for some weeks now in production without any problem and we offer it to now following a discussion here :

Diff Detail

rB Blender

Event Timeline

mathieu menuet (bliblubli) retitled this revision from to fixes wrong texture limit for OpenCL in Cycles.
mathieu menuet (bliblubli) updated this object.
mathieu menuet (bliblubli) set the repository for this revision to rB Blender.
Thomas Dinges (dingto) edited edge metadata.

2.76 is in Feature Freeze (RC2), an inclusion there is not possible.

well, it's more a fix (OpenCL shouldn't have any limit set actually?) than a feature I think. But I don't care as we have our own builds.

Sergey Sharybin (sergey) requested changes to this revision.Sep 25 2015, 10:21 PM
Sergey Sharybin (sergey) edited edge metadata.

This is really bad approach for solving the issue, especially for the AMD hardware which will compile the switch statement to huge if..else block which really kills the performance.

This is really to be solved by switching from packed textures and hardcoded texture names to texture objects which are available since kepler cards and opencl 1.2.

This revision now requires changes to proceed.Sep 25 2015, 10:21 PM

Well actually, the changes in switch statement are even never being compiled for OpenCL kernel, they only affect on CUDA and CPU kernels.

So the only thing needed to make textures work is to set tex_num_images to some high value when device is requesting packed images.

mathieu menuet (bliblubli) edited edge metadata.

corrected diff after comments from Sergey, thank you by the way, it's much easier like that and 2048 work on 390x in our test.

Sergey Sharybin (sergey) requested changes to this revision.Sep 26 2015, 9:28 AM
Sergey Sharybin (sergey) edited edge metadata.
Sergey Sharybin (sergey) added inline comments.

You should be checking whether images are to be packed or not here.


After checking note below it'll become clear that name of constant is misleading. Should be something like TEX_PACKED_NUM_IMAGES in it's own category.

This revision now requires changes to proceed.Sep 26 2015, 9:28 AM
mathieu menuet (bliblubli) edited edge metadata.
mathieu menuet (bliblubli) removed rB Blender as the repository for this revision.

Done. The OpenCL test is left until the CUDA kernel supports this.

This revision was automatically updated to reflect the committed changes.

Applied the patch with some other minor edits.

For the future -- please provide your real full name for a proper authorship.