Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Loading Textures in two separate threads at the same time doesn't work sometimes  (Read 565 times)
DanDixon
Customers
Community Member
*****
Posts: 181


« on: May 28, 2008, 08:24:36 PM »

Perhaps I'm doing something I'm not supposed to...

But I've found that trying to load textures in two separate streams will often cause one of the texture loads to fail.

Here's the error that I get:
Code:
05-27-2008 11:03:20 | TEXTURE MANAGER : Couldn't find the texture file ##MEMORY:22633444|59015.

The work around is pretty easy...

1 - Don't load textures in two separate threads at the same time.

Or

2 - Given this situation, where bmpPage is a System.Drawing.Bitmap (.net):

Code:
        Dim stream As New System.IO.MemoryStream
        Dim buffer() As Byte

        bmpPage.Save(stream, System.Drawing.Imaging.ImageFormat.Png)

        buffer = stream.ToArray()

        Dim pointer As IntPtr = System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0)
        Dim datasource As String = Globals.GetDataSourceFromMemory(pointer.ToInt32, buffer.Length)

Just keep retrying this line in a loop until the _TexID doesn't equal zero.
Code:
_TexID = TextureFactory.LoadTexture(datasource, "webpage", Engine.WebSizeX, Engine.WebSizeY, MTV3D65.CONST_TV_COLORKEY.TV_COLORKEY_NO, True) ' MTV3D65.CONST_TV_COLORKEY.TV_COLORKEY_BLACK)
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4479


WWW
« Reply #1 on: May 30, 2008, 03:07:11 PM »

Interesting, do the streams come from TVPackages or ?
TV is supposed to be able to handle several opened Streams at same time.
I will take a look but i guess it will be very hard to reproduce and debug.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Raine
Customers
Community Member
*****
Posts: 1190


« Reply #2 on: May 30, 2008, 05:24:26 PM »

I'll be working with streams too at some point, I'll be sure to let you know what I'll find, might help with the testing
Logged

DanDixon
Customers
Community Member
*****
Posts: 181


« Reply #3 on: May 30, 2008, 10:23:53 PM »

The stream comes from a System.Drawing.Bitmap(.net) which is created from a hidden internet explorer browser window. I'm positive that this Bitmap is good. Again... I just have to keep retrying TextureFactory.LoadTexture until it returns a texture ID that's greater than zero.

The other textures that are loaded in the other thread are all dds files and I've never had any issues loading them. I do load a single texture from a package, but it's loaded first before I create the 2nd thread that causes the problem.
« Last Edit: May 30, 2008, 10:29:50 PM by DanDixon » Logged
petroz
Community Member
*
Posts: 603


WWW
« Reply #4 on: May 31, 2008, 01:57:17 AM »

why not use make it a critical section?
Logged

Happiness is found in your kindness.

Project: BattleSpace
Gallery URL:
http://s235.photobucket.com/albums/ee185/PeterStirling
DanDixon
Customers
Community Member
*****
Posts: 181


« Reply #5 on: June 01, 2008, 04:18:20 PM »

why not use make it a critical section?

petroz... I don't understand your question.
Logged
Raine
Customers
Community Member
*****
Posts: 1190


« Reply #6 on: June 02, 2008, 12:23:30 PM »

I think he meant using thread lock primitives
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks