473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Texture.FromBitmap is slow runing from debugger

Hi,
Ive written a 3dmodel editor, and it works fairly well
it harldy uses any cpu exept when its loading a texture from bitmap
in the debugger, at all other times it hardly uses any cpu
but from the debugger even in release mode it takes a second or so
to load a 65k texture, with a 2ghz pc this is 10k instructions per pixel !

I cant understand what its doing here, can anyone shed any light on this ?

I have the d3d debug turned off although this makes zero difference.

yet it stil manages to actually draw the animated model meshes with <1% cpu.
in multi viewports, also load and decode the 20mb or so of files in under 1
second.

im using ..
Bitmap bitmap
Texture.FromBitmap(Draw3dDevice.device, bitmap, Usage.Dynamic,
Pool.Default);
bitmap is generated from memory. this may be somethign to do with it,
but i cant think what,
as I dont think it was slow when I was laoding bitmaps another way.

thanks
Colin =^.^=
Jun 27 '08 #1
7 2078
On Sun, 11 May 2008 03:45:09 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
Hi,
Ive written a 3dmodel editor, and it works fairly well
it harldy uses any cpu exept when its loading a texture from bitmap
in the debugger, at all other times it hardly uses any cpu
but from the debugger even in release mode it takes a second or so
to load a 65k texture, with a 2ghz pc this is 10k instructions per pixel
!
Where is the data in the Bitmap located? If you are copying data that's
in video memory already, that can indeed be very slow, depending on the
video bus your hardware has.

Beyond that, this is just not the newsgroup for your question. Your
question has zero to do with C# or .NET, and if you want a _good_ answer,
you need to post it in a newsgroup where it's on-topic and people familiar
with the issues are reading. For example, a newsgroup specifically about
using DirectX and/or using DirectX in managed code.

Pete
Jun 27 '08 #2
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sun, 11 May 2008 03:45:09 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
>Hi,
Ive written a 3dmodel editor, and it works fairly well
it harldy uses any cpu exept when its loading a texture from bitmap
in the debugger, at all other times it hardly uses any cpu
but from the debugger even in release mode it takes a second or so
to load a 65k texture, with a 2ghz pc this is 10k instructions per pixel
!

Where is the data in the Bitmap located? If you are copying data that's
in video memory already, that can indeed be very slow, depending on the
video bus your hardware has.

Beyond that, this is just not the newsgroup for your question. Your
question has zero to do with C# or .NET, and if you want a _good_ answer,
you need to post it in a newsgroup where it's on-topic and people familiar
with the issues are reading. For example, a newsgroup specifically about
using DirectX and/or using DirectX in managed code.

Pete
well its real fast without the debugger attatched...
so it must be something todo with c#/.net with the way the debugger
handles managed to unmanaged transitions although its using managed directx.

if i press ctrl-f5 to run the program independantly or run it normally it
runs
and loads the bitmaps almost instantly. same in both release and debug build
versions.
ive tried saving the bitmap to a memory stream and loading it from there.

Il ask in the gamers forum though thanks ...

Colin =^.^=
Jun 27 '08 #3
On Sun, 11 May 2008 14:53:27 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
well its real fast without the debugger attatched...
so it must be something todo with c#/.net with the way the debugger
handles managed to unmanaged transitions although its using managed
directx. [...]
Sorry. I missed the "debugger" aspect of your question. Reading too fast
I guess.

I still don't know the answer, but I suppose there's a slightly higher
chance of you getting an answer here than I first thought, if it's a
debugger-specific problem.

Pete
Jun 27 '08 #4

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sun, 11 May 2008 14:53:27 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
>well its real fast without the debugger attatched...
so it must be something todo with c#/.net with the way the debugger
handles managed to unmanaged transitions although its using managed
directx. [...]

Sorry. I missed the "debugger" aspect of your question. Reading too fast
I guess.

I still don't know the answer, but I suppose there's a slightly higher
chance of you getting an answer here than I first thought, if it's a
debugger-specific problem.

Pete
Yeah i dont seemed to have stated as specificaly as i first thought that it
is when the debuger is atatched
and not when it isnt atatched, its no real biggy, just takes 5 seconds
longer to do a debug cycle lol.
im more puzzled/curious than anything else.
although if i start trying to do it with masses of textures might be
anoying.

just like when its putting tons of stuff to the debugger output window it
sits there very slow but not even using any cpu power,
as if its deliberatly slowing the output so you can see it scroll past
easily ?
I also found a similar issue when trying to access the fast timer with the
debuger it was not fast.

I tried saving the bitmap to a memory stream and loading it from a stream
instead of memory
but made no difference, i will try doing it to a physical file next,
I think I did it this way before and didnt notice any speed issue,
but then again ive re written it all becuase it was all very slow before.
now its al nice and fast :D

many thanks
Colin =^.^=
Jun 27 '08 #5

Well after quite a lot of messing about I found that Texture.From...
is whats making it slow even loading from a memory stream
or a bitmap freshly loaded from a file,
but its only slow if the app is started with the debugger,
otherwise its plenty fast enough,

if I use TextureLoader its fast with the debugger,
but this cant load from a bitmap so I have to load from a file
but fortunatly its still fast if I load from a memory stream,
so il just keep my bitmaps as memory streams...

my gues is that there is some byte copying going on with the Texture.From
that is going acros the interface for each byte.

Colin =^.^=
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sun, 11 May 2008 14:53:27 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
>well its real fast without the debugger attatched...
so it must be something todo with c#/.net with the way the debugger
handles managed to unmanaged transitions although its using managed
directx. [...]

Sorry. I missed the "debugger" aspect of your question. Reading too fast
I guess.

I still don't know the answer, but I suppose there's a slightly higher
chance of you getting an answer here than I first thought, if it's a
debugger-specific problem.

Pete

Jun 27 '08 #6
On Mon, 12 May 2008 06:12:28 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
>
Well after quite a lot of messing about I found that Texture.From...
is whats making it slow even loading from a memory stream
or a bitmap freshly loaded from a file,
but its only slow if the app is started with the debugger,
otherwise its plenty fast enough,

if I use TextureLoader its fast with the debugger,
but this cant load from a bitmap so I have to load from a file
but fortunatly its still fast if I load from a memory stream,
so il just keep my bitmaps as memory streams...

my gues is that there is some byte copying going on with the Texture.From
that is going acros the interface for each byte.
Just a thought: it's possible you are running into some sort of
driver-level copy protection. Have you tested this on different hardware
(and thus different drivers)? Some drivers annoyingly will actually check
to see if a debugger is present and will go through a different code path
if so. Applications that do lower-level things sometimes will run into
problems, and it's possible that your program's interaction with DirectX
is low enough level for the driver to notice.

Usually it's something really annoying like refusing to process certain
kinds of input altogether. But I suppose there could be some sort of
performance degradation. Ironically, if it is related to that, it's
almost definitely not intentional and is just a bug in the driver's
anti-copying logic (for example, it's checking constantly to see if you're
creating video memory surfaces that it considers "legal" and the overhead
of checking is killing your performance).

It's possible that you can do some testing on your immediate hardware
rather than switching computers by reducing or turning off hardware
acceleration in the video driver settings, or otherwise manipulating the
driver settings so that you're either not using that particular driver, or
you're disabling features that might interact in this way.

Pete
Jun 27 '08 #7
thanks, I dont realy know if this is the case or not,
although ive avoided it by using TextureLoader instead.

however I do know that runing from the debugger in c# express 2005
seemingly adds a lot to the native-managed transition,
this came to light when trying to acces the hi res cpu timer
in the debugger this took so long that it was more acurate to use the
low res system timer. again this only ocured in the debuger,
using ctrl-f5 was fine. relase or debug build gave same results.

if its doing a lot of transistions (say one per pixel) then this would
explain things.
its also managed directx wich is old and abandoned,
but as its part of .net 2.0 it does mean its one less library
I have to wory about.

I have also tried it with the debug directx drivers turned on
and i have found no noticble change in performance either way.

I have a lot of light map textures to create and I might try and do this on
the fly,
as it was very slow before, but i was using opengl.

Colin =^.^=

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Mon, 12 May 2008 06:12:28 -0700, colin <co*********@ntworld.NOSPAM.com>
wrote:
>>
Well after quite a lot of messing about I found that Texture.From...
is whats making it slow even loading from a memory stream
or a bitmap freshly loaded from a file,
but its only slow if the app is started with the debugger,
otherwise its plenty fast enough,

if I use TextureLoader its fast with the debugger,
but this cant load from a bitmap so I have to load from a file
but fortunatly its still fast if I load from a memory stream,
so il just keep my bitmaps as memory streams...

my gues is that there is some byte copying going on with the Texture.From
that is going acros the interface for each byte.

Just a thought: it's possible you are running into some sort of
driver-level copy protection. Have you tested this on different hardware
(and thus different drivers)? Some drivers annoyingly will actually check
to see if a debugger is present and will go through a different code path
if so. Applications that do lower-level things sometimes will run into
problems, and it's possible that your program's interaction with DirectX
is low enough level for the driver to notice.

Usually it's something really annoying like refusing to process certain
kinds of input altogether. But I suppose there could be some sort of
performance degradation. Ironically, if it is related to that, it's
almost definitely not intentional and is just a bug in the driver's
anti-copying logic (for example, it's checking constantly to see if you're
creating video memory surfaces that it considers "legal" and the overhead
of checking is killing your performance).

It's possible that you can do some testing on your immediate hardware
rather than switching computers by reducing or turning off hardware
acceleration in the video driver settings, or otherwise manipulating the
driver settings so that you're either not using that particular driver, or
you're disabling features that might interact in this way.

Pete

Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark L | last post by:
I am trying to create a graphics engine using OpenGL and PHP. I am currently trying to create a completly white texture to test out the texturing capabilities. My idea is to create an array...
3
by: Doug Baroter | last post by:
Hi, I have a small Access 97 database (~2.5 MB), which has about 9 user tables, and data are normalized up to 3NF. I'm using a third party tool/language for web interface application. I just...
1
by: Myk Quayce | last post by:
I have a four-sided polygon that rotates and zooms as the user moves the mouse. Is there a way to incorporate a texture-mapped image without DirectX? The GDI+ doesn't seem to support this. -- ...
1
by: Brian Henry | last post by:
I know some of you have seen this problem. Stepping through code in the debugger is slow as heck in Visual Studio 2005. Well here is the problem, Edit and continue. Because edit and continue does...
6
by: DCC-700 | last post by:
I am running VB for ASP.Net in VS.Net 2003 and am experiencing extremely slow response in the ide at times and the debugger. Below is additional detail on the problem. Any thoughts are much...
3
by: x | last post by:
Still fairly new at this, I have been trying to find out how to compile and effect with multiple samplers. Been able to find loads of examples that show the HSL code once the samplers are...
2
by: =?ISO-8859-2?Q?Rafa=B3?= Maj | last post by:
Say we have a class Model (a 3d model) and class Texture (representing an Texture). Model have a texture, Model can be Drawed. Texture have method that returns data needed for drawing. class...
0
by: ...:::JA:::... | last post by:
Hello, Is there any real easy example for loading an texture in your directpython window??? For example this is my code: # loading directpython modules import d3dx import d3d from d3dc...
0
by: brixton | last post by:
Hello, I've got the following code that creates a texture from a .RAW file: GLuint MyGLCanvas::LoadTextureRAW( const char * filename, int wrap ) { GLuint texture; int width, height; ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.