Skip to content
This repository was archived by the owner on Aug 9, 2019. It is now read-only.
This repository was archived by the owner on Aug 9, 2019. It is now read-only.

(Crash)Grass Clusters CMeshBuilder::BeginModify Not Safe With Queued Material System #4

Description

@Spirrwell

When using the multi-threaded queued materialsystem (mat_queue_mode -1, which is default in SDK2013) and modifying the grass mesh in the CGrassClusterManager::InjectMorph with CMeshBuilder's BeginModify function, there's a potential for a crash. On Windows it doesn't really happen, but on Linux/Mac it's an instant crash.

The way to handle this is to use the render context's call queue.

Here's some pseudo-code as to what that might look like.

CMatRenderContextPtr pRenderContext( materials );

ICallQueue *pCallQueue = pRenderContext->GetCallQueue();

if ( pCallQueue )
	pCallQueue->QueueCall( this, &CGrassClusterManager::SomeThreadSafeMorphFunc );
else
	DoSingleThreadedMorph()

You'll also want a mutex to lock using AUTO_LOCK or something to protect access to the cluster data/grass mesh.

I'm working on something like this, so I may do a pull request even though this project is dead, but I figured I'd post this issue in case somebody finds this and cares about it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions