Jump to content
  • Advertisement

begemot

Member
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

103 Neutral

About begemot

  • Rank
    Member
  1. Hi! Help me please to resolve the next problem. I have source picture in YUV format, saved in ARGB texture. In my effect in first pass I transform it. It is ok. But if my picture will be resized, it looks very poorly((((((( So, I think I need apply any filters to my result image. How I can do it? I try set parameters as [font=Consolas][size=2][font=Consolas][size=2]device.SetSamplerState(0, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].MinFilter, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]device.SetSamplerState(0, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].MagFilter, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]device.SetSamplerState(0, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].MipFilter, [/font][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/font][/font] but they effects on source texture and my result image is very very bad. How I can apply filters only after first pass? One way was in getting image after first pass, creating sampler in effect as [font=Consolas][size=2][font=Consolas][size=2]texture rT2;[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]sampler resultTex2 = sampler_state[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]{[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]Texture = (rT2);[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]MinFilter = LINEAR;[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]MagFilter = LINEAR;[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]MipFilter = LINEAR;[/font][/font] [font=Consolas][size=2][font=Consolas][size=2]};[/font][/font] and start second simple pass) If it is a good way, how I can get image after first pass and put it to sampler?
  2. begemot

    transfer byte[] to effect

    Thank you very much
  3. begemot

    transfer byte[] to effect

    I use line per line CopyMemory from kernel32.dll because I don't understand how copy data from IntPtr to IntPtr by Marshal.Copy. It seems to me, It works a little bit faster then primary unsafe code.
  4. begemot

    transfer byte[] to effect

    the function CopyMemory costs 52%
  5. begemot

    transfer byte[] to effect

    Also YUV->RGB conversion was discussed. Can you help me in this? Can I get frames from my video files in YUV format or I must do any convertions between getting frame and copying steps?
  6. begemot

    transfer byte[] to effect

    My problem is in copying a lot of memory in textures. I need execute operation of updating for 36 images with rate 25 times per second. If I have images 300x200 size I takes about 60 ms for copying and display. But if my pictures reach 700x500 size it takes just 150 ms (I tested with 16bpp format). I think to resize my images before copying, but I don't know how to do it. can ipp libs do it? Is it realy?
  7. begemot

    transfer byte[] to effect

    I have texture and can do next operation [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]using[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Surface[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] surface = t.GetSurfaceLevel(0))[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font] [font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]DataRectangle[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] dr = surface.LockRectangle([/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]LockFlags[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].Discard);[/font][/font] [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] d_pit = dr.Pitch;[/font][/font] [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]for[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] j = 0; j < heightdef; j++)[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]CopyMemory(dr.Data.DataPointer.ToInt32() + j*d_pit,[/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]ptr.ToInt32() + [/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]j*pit,[/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]d_pit);[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]surface.UnlockRectangle();[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]then I pass it to shader.[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]Is it the fastest way? [/font][/font]
  8. begemot

    transfer byte[] to effect

    But I don't understand how I pass my surface to shader.. I can create texture, Get surface as [font="Consolas"][size="2"][font="Consolas"][size="2"]Texture.GetSurfaceLevel(0)[/font][/font], [font="Consolas"][size="2"][font="Consolas"][size="2"]update surface using line per line CopyMemory and pass to shader texture. Is it right?[/font][/font]
  9. begemot

    transfer byte[] to effect

    I tested creating texture from memory using Texture.FromMemory () (Nik02 was right in data format - it must contain BITMAPINFOHEADER),but it is very slow.. Now I do CopyMemory -this way a little bit faster when unsafe copying. Working with video memory throw surfaces is faster then throw textures?
  10. begemot

    transfer byte[] to effect

    Which of ways of creating texture you suppose is the fastest? Texture.FromMemory Texture.FromStream new Texture() and copy data
  11. begemot

    transfer byte[] to effect

    May be, those copying code can be exclude in the following ways: 1. My idea to put bytes to shader/effect 2. Create texture from memory. In this case I have error in code [font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Texture[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].FromMemory(device, imageBytes,widthdef,heightdef,1,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Usage[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Format[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].A8R8G8B8,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Pool[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Default,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Filter[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Filter[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Color[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].White.ToArgb())[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"]In what I'm mistake?[/font][/font] 3. Create one - dimension texture and pass it to shader/effect
  12. begemot

    transfer byte[] to effect

    It seems to me, that I can not use Marshal.Copy so as pitch of source image not equals texture's pitch at times.. I'm dreaming to remove this copying process.. Yes. I need get and display frames from video file in realtime mode)))
  13. begemot

    transfer byte[] to effect

    May be creating parameters are not optimized? or code to fill?
  14. begemot

    transfer byte[] to effect

    I need to use D3D9.. Now I create texture as [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]new[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"] [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Texture[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"](device, w[/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"], h[/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"], 1, [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Usage[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Dynamic, [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Format[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].A8R8G8B8,[/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Pool[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Default);[/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"]and then fill it [/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]DataRectangle[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] a_ = t.LockRectangle(0, [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]LockFlags[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].None);[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] pitch = (([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"])a_.Pitch / [/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]sizeof[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]));[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]DataStream[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] a = a_.Data;[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]unsafe[/font][/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]* to = ([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]*)a.DataPointer;[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]* from = ([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]*)ptr.ToPointer();[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]for[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] j = 0; j < heightdef; j++)[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]for[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/font][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] i = 0; i < pit; i++)[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]to[i + j * pitch] = from[i + j * pit];[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]t.UnlockRectangle(0);[/font][/font][/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] [/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] [/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]then I can set it to my effect to texture parameter: effect.SetTexture("Tex",t). [/font][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] Is exist any faster way to update texture in effect?[/font][/font]
  15. I have byte array of image's data (or pointer). I have effect with pixel shader to fill result texture. I want to work with my image data in pixel shader without unnecessary transformations. How I can transfer bytes array to my Effect and how I must define it in HLSL program? I'm using SlimDX and C#. Help me,please!!!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!