Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 18 Dec 2002
Online Last Active Today, 11:21 PM

Posts I've Made

In Topic: [SlimDX] Texture2D.ToStream() throws an Undetermined Error

Yesterday, 04:41 AM

No prob, glad I could help smile.png


The ToStream method is likely slow for two reasons:

  • When you write primitive data types to a stream, each write invokes other functionality than a simple memory write. This is as opposed to using your own array, which is essentially just a linear block of memory with fast access. The latter is more unsafe, but very much faster approach. And it is not actually unsafe if you know what you're doing (do sanity checking on memory boundaries at high level etc.)
  • The image codec itself is slow to instantiate/invoke. Apart from switching to a faster image i/o library, there's little you can do about the issue itself. However, you could use a separate thread if you need to save and image while keeping rendering alive - just map/copy the raw pixels in the main drawing thread, and do the actual file i/o in the secondary thread.

In Topic: [SlimDX] Texture2D.ToStream() throws an Undetermined Error

26 January 2015 - 12:16 PM

I mainly work on the native D3D, but I believe it has equivalent functionality to map a subresource. "Mapping" in this context refers to requesting a pointer to resource data, and effectively denying other parties' access to it until you subsequently unmap it. In native d3d, mapping gives you the data pointer directly.

In Topic: [SlimDX] Texture2D.ToStream() throws an Undetermined Error

26 January 2015 - 10:37 AM

The ToStream method itself may be the bottleneck. Try to map and copy the texture data manually to your own array; if it is faster, you can verify this.
Note that downloading from the gpu is generally slower than uploading, since a greater amount of bus bandwidth is usually allocated for upload traffic.

In Topic: [SlimDX] Texture2D.ToStream() throws an Undetermined Error

25 January 2015 - 04:22 AM

The texture is not in cpu-accessible memory, so the ToFile method cannot get the data to do its thing.


You need to create a staging texture (which is CPU-accessible), copy your current texture contents to it, and save the said staging texture. Staging resources are special in that both the GPU and CPU can access them, but you can't use them directly for rendering.

In Topic: Save/Load in C# XNA

14 January 2015 - 01:06 AM

The relevant keyword here is "serialization", not "threading".

The general idea is that you write a representation of your game state to a file, and subsequently construct a game state from said representation.

For almost all modern programming languages, a library exists (often in base class library) that allows you to serialise a given object to permanent storage (or other stream) and to deserialize it back to a runtime object instance.