Re: DirectX is too slow




"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in message
news:umnEQlMoHHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
For those wondering what I mean by slow, download the attachment and see
the difference.

Pardon the huge binary. In the zip file is ctlPictDraw.dll (managed
DirectX), TestPictDraw.exe (VB2005 using the dll) and lastly TestDraw.exe
(VB6 standalone)

Both exe's do the same job !!!!!

Galen


"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in message
news:ewjU7ZIoHHA.716@xxxxxxxxxxxxxxxxxxxxxxx
I have a dll for the DirectX drawing routines. I use
PrimitiveType.LineStrip
to draw six lines at a time (real time data will arrive in groups of 6).

I use QueryPerformanceCounter to time how long it takes to draw 6 lines.
I
can redraw over and over by hitting a Button.

The minimum time is about 15 milliseconds, maximum about 30 ms and the
average around 20 ms. This is unacceptably slow for my use.

Does anyone see anything in the code below that could be causing this
timing
problem??

Not shown is setting up SoundsAry with a continuous triangle wave for
display.

HERE'S THE MAIN PROGRAM LOOP DRAWING 1019 LINES IN GROUPS OF 6
PictDraw1.PictMode = 6 'vertices
ArgX1 = 0
Count = 0
For Index = 0 To 169
If Index = 33 Then QueryPerformanceCounter(Ctr1)
For Inner = 0 To 5
ArgY1(Inner) = SoundsAry(Count)
Count = Count + 1
Next
PictDraw1.DoVerts(ArgX1, ArgY1, Color.Black)
ArgX1 = ArgX1 + 6
If Index = 33 Then QueryPerformanceCounter(Ctr2)
If Index = 35 Then
QueryPerformanceFrequency(Freq)
Label1.Text = CStr((Ctr2 - Ctr1) / Freq)
Label1.Refresh()
End If
Next

HERES THE DLL ROUTINE SETTING UP THE DIRECTX
Public Property PictMode() As Integer
Get
Return Mode
End Get
Set(ByVal value As Integer)
Dim Index As Short
Mode = value '0= not sweeps 1 up=maximum number of
vertices
If Mode <> 0 Then
Skipflg = False
Panel1.Visible = False
Dim d3dpp As PresentParameters = New PresentParameters()

d3dpp.SwapEffect = SwapEffect.Discard
d3dpp.Windowed = True

d3dDevice = New Device(0, DeviceType.Hardware, Me, _
CreateFlags.SoftwareVertexProcessing, d3dpp)
VerBuf = New
VertexBuffer(GetType(CustomVertex.TransformedColored), Mode, _
d3dDevice, Usage.Dynamic Or Usage.WriteOnly,
CustomVertex.TransformedColored.Format, _
Pool.Default)
d3dDevice.Clear(ClearFlags.Target, Me.BackColor, 1.0F, 0)
d3dDevice.RenderState.Lighting = False

NumVerts = Mode
ReDim Verts(Mode - 1)
For Index = 0 To NumVerts - 1
Verts(Index).Z = 0.5F
Verts(Index).Rhw = 1
Next Index

Else


HERE'S THE DLL ROUTINE DRAWING LINES 6 AT A TIME.
Public Sub DoVerts(ByVal X1 As Integer, ByVal Y1() As Short, ByVal
Value
As Color)
Dim Index As Short
Verts(0).X = X1
Verts(0).Y = Y1(0)
Verts(0).Color = Value.ToArgb
X1 = X1 + 1
For Index = 1 To NumVerts - 1
Verts(Index).X = X1
Verts(Index).Y = Y1(Index)
Verts(Index).Color = Value.ToArgb
X1 = X1 + 1
Next Index

Strm = VerBuf.Lock(0, 0, 0)
' Strm.Position = 0
Strm.Write(Verts)
VerBuf.Unlock()
d3dDevice.BeginScene()
d3dDevice.VertexFormat = CustomVertex.TransformedColored.Format
d3dDevice.SetStreamSource(0, VerBuf, 0)
d3dDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, NumVerts - 1)
d3dDevice.EndScene()
d3dDevice.Present()

End Sub

Galen




Sarcasm
Thanks for the help
/Sarcasm

Galen


.



Relevant Pages

  • Re: VB2005 timing/speed problem
    ... That plus the fact that after calling into the dll, ... ActiveX dll I could run the dll in another thread during the data collection ... platform API directly, or DirectX, instead of GDI+ in .NET. ... consider add a "queue" before your USD device and your .NET application: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: change d3dx9 dll version
    ... Well, at your suggestion, Wessam, I tried setting ... Microsoft DirectX MVP, ... DirectX 9.0 SDK Update Dec. 04. ... Since D3DX is a DLL, you need to use DirectSetup when you deploy your ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: why i can not run the program which need directx 9.0c,while xp
    ... i did checked with dependcywalker, but i don't know how to get useful ... because it show so many DLL it rely on. ... The application might need more than just DirectX 9.0c. ... I created a XPE image run on the windows based terminals ...
    (microsoft.public.windowsxp.embedded)
  • Re: definition clarification needed: what is a component in com?
    ... A single DLL can have multiple components, ... multiple DLLs can comprise a single component. ... DirectX is comprised of several components - DirectDraw, ... but also i've seen it defined as a binary file (.dll or .exe file) ...
    (microsoft.public.win32.programmer.ole)
  • Re: Calling a VB DLL Methods external to .NET
    ... MsgBox("This is a helloworld EXAMPLE from a VB.NET DLL exposed to COM") ... ' A creatable COM class must have a Public Sub New ... > of the public sub based on the interface definition. ... > My problem is when I attempt to call the "displaynumber" method I get an ...
    (microsoft.public.dotnet.languages.vb)