Homebrew Homebrew Development

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
What does get_message do? Based on the limited information it looks like you are exiting the thread after reading a single message. To answer your question accurately I would need to see more code - for instance the context for signaling the event.
What does get_message do?
Code:
static int sock_receive(char* message, size_t size) {
    int len;
    len = recv(chatls, message, size, 0);
  
    if (len == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK) {
            return -1;
        }
    }
    return len;
}
void get_message() {
    char message[500] = "";
    int n = sock_receive(message, 500);
    if(n > 0) {
        add_message(message, 1, white, background_message);
    }
    else {
        exitReceive = true;
    }

}
It waits on the server to send a message.
That is why i would need to use a thread.
sock_receive() keeps running until it receives an answer.

it looks like you are exiting the thread after reading a single message
The threads only exits when i shut the server down.
it keeps running, i've tested this.

the context for signaling the event.
At the beginning of the script i create the sockets and i signal the event to start listening.
If i would use get_message() in the beginning in the loop, i get the exact same result, so the thread does literally the same as the function call.

What i want it to do
I want my code to keep checking on new messages, but since recv only stops running when it actually receives a message, I need to do it simultaneously with my main thread.

So basically what I need is that the function sock_recv() keeps running on the background, while my main loop keeps running as well.

EDIT: found this in a c forum "If it's asyncronous, it will. If it's synchronous, it usually blocks until it receives something.".
So I'm gonna try to make it asynchronous?
EDIT: Gonna play a little with select() and poll() to see if there is a message that i can recv()
But the threads are useless for me in this case.
 
Last edited by Tjessx,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,029
Country
United States
What does get_message do?
Code:
static int sock_receive(char* message, size_t size) {
    int len;
    len = recv(chatls, message, size, 0);
 
    if (len == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK) {
            return -1;
        }
    }
    return len;
}
void get_message() {
    char message[500] = "";
    int n = sock_receive(message, 500);
    if(n > 0) {
        add_message(message, 1, white, background_message);
    }
    else {
        exitReceive = true;
    }

}
It waits on the server to send a message.
That is why i would need to use a thread.
sock_receive() keeps running until it receives an answer.

it looks like you are exiting the thread after reading a single message
The threads only exits when i shut the server down.
it keeps running, i've tested this.

the context for signaling the event.
At the beginning of the script i create the sockets and i signal the event to start listening.
If i would use get_message() in the beginning in the loop, i get the exact same result, so the thread does literally the same as the function call.

What i want it to do
I want my code to keep checking on new messages, but since recv only stops running when it actually receives a message, I need to do it simultaneously with my main thread.

So basically what I need is that the function sock_recv() keeps running on the background, while my main loop keeps running as well.

EDIT: found this in a c forum "If it's asyncronous, it will. If it's synchronous, it usually blocks until it receives something.".
So I'm gonna try to make it asynchronous?
EDIT: Gonna play a little with select() and poll() to see if there is a message that i can recv()
But the threads are useless for me in this case.
You don't need a thread to do this. You can do this in your main thread if you set the socket to non-blocking. if the socket is non-blocking the recv will return immediately if there is nothing to receive. The socket service is buffering incoming packets so you don't need to recv in realtime.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
You don't need a thread to do this. You can do this in your main thread if you set the socket to non-blocking. if the socket is non-blocking the recv will return immediately if there is nothing to receive. The socket service is buffering incoming packets so you don't need to recv in realtime.
You have no idea how long i searched for this answer, just read it on the 50sth stack exchange topic i read about this.
Thanks!
EDIT: works
 
Last edited by Tjessx,

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,455
Country
United States
I figured out why rendering to a 1024x1024 buffer doesn't work. It's partially a hardware limitation, and partially how GPU_SetViewport is programmed designed. The hardware is limited to a maximum render area of 1023x1016 pixels before it starts having problems. A width greater than 1023 prevents any polygons from being rendered, while a height greater than 1016 (when width is 1023 or less) causes the system to hang. What I found out was that I can render in sections of 512x512 in each of the 4 corners to produce the overall render. However, the current implementation of GPU_SetViewport needs to be adjusted, as it modifies both the viewport settings and the destination color/depth buffers together, making the X/Y offsets produce incorrect results when not set to 0 when the viewport size is not the same size as the destination buffer sizes.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,029
Country
United States
I figured out why rendering to a 1024x1024 buffer doesn't work. It's partially a hardware limitation, and partially how GPU_SetViewport is programmed designed. The hardware is limited to a maximum render area of 1023x1016 pixels before it starts having problems. A width greater than 1023 prevents any polygons from being rendered, while a height greater than 1016 (when width is 1023 or less) causes the system to hang. What I found out was that I can render in sections of 512x512 in each of the 4 corners to produce the overall render. However, the current implementation of GPU_SetViewport needs to be adjusted, as it modifies both the viewport settings and the destination color/depth buffers together, making the X/Y offsets produce incorrect results when not set to 0 when the viewport size is not the same size as the destination buffer sizes.
it sounds like you are working on something really interesting... is it still a secret?
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,455
Country
United States
Seems my idea is hitting a bottleneck, as tests are showing that even if the GPU is handling it all via polygon rendering and freeing up the CPU, it still takes quite a bit of time to fill up a 1024x1024 texture area. Reducing the overall texture to 512x512 helps a lot, but the resulting detail would be reduced, and I'm trying not to have to resort to that if possible. The thing though is that what I'm doing is simply rendering from a smaller texture multiple times onto a bigger texture, and I don't need anything like a depth buffer, special culling, etc. All I want to do is copy from the smaller to the bigger.

Having saw a function like GX_RequestDma, I wonder if I can use something like that, but in more of a command list form like what I'm currently doing for rendering, so it would not need to be manually called, as what I would require is having to use such a function thousands of times per frame. The CPU time spent having to call it that many times would be best spent elsewhere if something else could do it automatically, like in a pre-made command list.
 

Jim_e

Well-Known Member
Newcomer
Joined
Nov 13, 2007
Messages
79
Trophies
0
XP
267
Country
United States
what I would require is having to use such a function thousands of times per frame
I assumed you were trying to do some trickery to get around the palette color issue. Now I'm not sure what you are at that needs to run thousands of time per frame.

Sorry I can't be of any help, you seem to be in completely uncharted waters.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,029
Country
United States
Seems my idea is hitting a bottleneck, as tests are showing that even if the GPU is handling it all via polygon rendering and freeing up the CPU, it still takes quite a bit of time to fill up a 1024x1024 texture area. Reducing the overall texture to 512x512 helps a lot, but the resulting detail would be reduced, and I'm trying not to have to resort to that if possible. The thing though is that what I'm doing is simply rendering from a smaller texture multiple times onto a bigger texture, and I don't need anything like a depth buffer, special culling, etc. All I want to do is copy from the smaller to the bigger.

Having saw a function like GX_RequestDma, I wonder if I can use something like that, but in more of a command list form like what I'm currently doing for rendering, so it would not need to be manually called, as what I would require is having to use such a function thousands of times per frame. The CPU time spent having to call it that many times would be best spent elsewhere if something else could do it automatically, like in a pre-made command list.
The transfer engine is supposed to be able to handle this. It is supposed to be able to copy to/from blocks with different strides. So you should be able to use it to tile an image. Maybe I misunderstood what you are trying to do though.
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,455
Country
United States
The transfer engine is supposed to be able to handle this. It is supposed to be able to copy to/from blocks with different strides. So you should be able to use it to tile an image. Maybe I misunderstood what you are trying to do though.

If the transfer engine could copy from various locations in a given area (VRAM or FCRAM) using an array to determine which location to take from (like block 0, then 2, 5, 1, 0, 0, etc), all the same length, into a destination area (VRAM specifically if possible) in sequential order (0, 1, 2, 3, etc), then that would make my day. Would still need to test if doing thousands of DMA requests manually would result in better performance than the current rendering method.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,029
Country
United States
If the transfer engine could copy from various locations in a given area (VRAM or FCRAM) using an array to determine which location to take from (like block 0, then 2, 5, 1, 0, 0, etc), all the same length, into a destination area (VRAM specifically if possible) in sequential order (0, 1, 2, 3, etc), then that would make my day. Would still need to test if doing thousands of DMA requests manually would result in better performance than the current rendering method.
Here is the link for 3dbrew if you have not looked at it already http://3dbrew.org/wiki/GPU/External_Registers#Transfer_Engine
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,455
Country
United States

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,455
Country
United States
Gah! Thought doing DMA requests would be a good way to handle my situation, but unfortunately, it's far-far slower than the render-to-texture method I had. Because I'd do numerous requests in a loop, it would hang the system if I didn't also tell it to wait for DMA to be ready after each transfer. Seems nothing I try is going to be very efficient for my idea. The only avenue that seems to not be a bad thing regarding processing is to reduce from 1024x1024 to 512x512, but then texture detail would drop.
 

Jim_e

Well-Known Member
Newcomer
Joined
Nov 13, 2007
Messages
79
Trophies
0
XP
267
Country
United States
Because I'd do numerous requests in a loop, it would hang the system if I didn't also tell it to wait for DMA to be ready after each transfer
Are there no interrupts that trigger after a DMA that would let you issue another request Immediately? Or is the Interrupt OS controlled?

What about mixing Texture Rendering and DMA?
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
How should i convert an u64 to char* in c?
Have tried so many things but i vant find the solution for this
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Xdqwerty @ Xdqwerty:
    Good morning
  • Xdqwerty @ Xdqwerty:
    Out of nowhere I got several scars on my forearm and part of my arm and it really itches.
  • AdRoz78 @ AdRoz78:
    Hey, I bought a modchip today and it says "New 2040plus" in the top left corner. Is this a legit chip or was I scammed?
  • Veho @ Veho:
    @AdRoz78 start a thread and post a photo of the chip.
    +2
  • Xdqwerty @ Xdqwerty:
    Yawn
  • S @ salazarcosplay:
    and good morning everyone
    +1
  • K3Nv2 @ K3Nv2:
    @BakerMan, his partner is Luke
  • Sicklyboy @ Sicklyboy:
    Sup nerds
    +1
  • Flame @ Flame:
    oh hi, Sickly
  • K3Nv2 @ K3Nv2:
    Oh hi flame
  • S @ salazarcosplay:
    @K3Nv2 what was your ps4 situation
  • S @ salazarcosplay:
    did you always have a ps4 you never updated
  • S @ salazarcosplay:
    or were you able to get new ps4 tracking it \
    as soon as the hack was announced
  • S @ salazarcosplay:
    or did you have to find a used one with the lower firm ware that was not updated
  • K3Nv2 @ K3Nv2:
    I got this ps4 at launch and never updated since 9.0
  • K3Nv2 @ K3Nv2:
    You got a good chance of buying a used one and asking the seller how often they used or even ask for a Pic of fw and telling them not to update
  • RedColoredStars @ RedColoredStars:
    Speaking of PLaystation. I see Evilnat put out a beta for PS3 CFW 4.91.2 on the 22nd.
  • K3Nv2 @ K3Nv2:
    Don't really see the point in updating it tbh
  • BigOnYa @ BigOnYa:
    Yea you right, I thought about updating my PS3 CFW to 4.91, but why really, everything plays fine now. I guess for people that have already updated past 4.9 it would be helpful.
  • K3Nv2 @ K3Nv2:
    Idk if online servers are still active that would be my only thought
    +1
  • BigOnYa @ BigOnYa:
    Thats true, personally I don't play it online at all, in fact, I deleted all wifi details on it once I installed CFW, so it won't connect and auto-update itself
  • BigOnYa @ BigOnYa:
    I play most games that are on both PS3/360 strickly on the 360, but PS3 exclusives are really only games I play on the PS3 (You know me, I'm more of a Xbox junkie)
  • K3Nv2 @ K3Nv2:
    Ps3 really has no titles worth going online over nps is the only reason you'd want wifi
    K3Nv2 @ K3Nv2: Ps3 really has no titles worth going online over nps is the only reason you'd want wifi