begemot

Members
  • 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, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].MinFilter, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]device.SetSamplerState(0, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].MagFilter, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]device.SetSamplerState(0, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]SamplerState[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].MipFilter, [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]TextureFilter[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].Linear);[/size][/font][/size][/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;[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]sampler resultTex2 = sampler_state[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]{[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]Texture = (rT2);[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]MinFilter = LINEAR;[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]MagFilter = LINEAR;[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]MipFilter = LINEAR;[/size][/font][/size][/font] [font=Consolas][size=2][font=Consolas][size=2]};[/size][/font][/size][/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. transfer byte[] to effect

    Thank you very much
  3. 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. transfer byte[] to effect

    the function CopyMemory costs 52%
  5. 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. 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. 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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Surface[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] surface = t.GetSurfaceLevel(0))[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]{[/size][/font][/size][/font] [font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]DataRectangle[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] dr = surface.LockRectangle([/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]LockFlags[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].Discard);[/size][/font][/size][/font] [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] d_pit = dr.Pitch;[/size][/font][/size][/font] [font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]for[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] j = 0; j < heightdef; j++)[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]CopyMemory(dr.Data.DataPointer.ToInt32() + j*d_pit,[/size][/font][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]ptr.ToInt32() + [/size][/font][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]j*pit,[/size][/font][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]d_pit);[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]surface.UnlockRectangle();[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]}[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]then I pass it to shader.[/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]Is it the fastest way? [/size][/font][/size][/font]
  8. 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)[/size][/font][/size][/font], [font="Consolas"][size="2"][font="Consolas"][size="2"]update surface using line per line CopyMemory and pass to shader texture. Is it right?[/size][/font][/size][/font]
  9. 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. 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. 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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].FromMemory(device, imageBytes,widthdef,heightdef,1,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Usage[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Format[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].A8R8G8B8,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Pool[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Default,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Filter[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Filter[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].None,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Color[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].White.ToArgb())[/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"]In what I'm mistake?[/color][/size][/font][/size][/font] 3. Create one - dimension texture and pass it to shader/effect
  12. 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. transfer byte[] to effect

    May be creating parameters are not optimized? or code to fill?
  14. 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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"] [/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Texture[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"](device, w[/color][/size][/font][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"], h[/color][/size][/font][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"], 1, [/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Usage[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Dynamic, [/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Format[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].A8R8G8B8,[/color][/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Pool[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"].Default);[/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"]and then fill it [/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] a_ = t.LockRectangle(0, [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]LockFlags[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].None);[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] pitch = (([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"])a_.Pitch / [/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]sizeof[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]));[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] a = a_.Data;[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]{[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]* to = ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]*)a.DataPointer;[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]* from = ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]ushort[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]*)ptr.ToPointer();[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] j = 0; j < heightdef; j++)[/size][/font][/size][/font][/color][/size][/font][/size][/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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] i = 0; i < pit; i++)[/size][/font][/size][/font][/color][/size][/font][/size][/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];[/size][/font][/size][/font][/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]}[/size][/font][/size][/font][/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"][font="Consolas"][size="2"][font="Consolas"][size="2"]t.UnlockRectangle(0);[/size][/font][/size][/font][/color][/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"]then I can set it to my effect to texture parameter: effect.SetTexture("Tex",t). [/size][/font][/size][/font] [font="Consolas"][size="2"][font="Consolas"][size="2"] Is exist any faster way to update texture in effect?[/size][/font][/size][/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!!!